首页 > 其他 > 详细

返回指针的函数

时间:2015-03-11 19:18:56      阅读:243      评论:0      收藏:0      [点我收藏+]

 

/*
1. 看懂语法
2. 定义指向函数的指针:
    double(*p)(double,char *,int);
    p = haha;
    or
    double (*p)(double,char *,int)=haha;
3.如何间接调用函数
    1. p(19.7,"jack",10);
    2. (*p)(19.7,"jack",10); 


*/ 
#include <stdio.h>
int main(int argc, char *argv[])

void test(){
    
    printf("利用指针调用函数\n");
    
}
{
    // (*p)是固定写法,代表指针比那辆p将来肯定指向参数函数 
    //左边的void:指针 变量p指向的函数没有返回值
    //右边的():指针变量p指向的函数没有形参; 
    void (*p)();
    /////////////////////////////////////// 
    p = test;//指针变量p指向了test函数
    
    (*p)();//利用指针变量间接调用函数
    test();//直接调用函数
    p();//这种方法=test(),因为p=test了 
    
    return 0;
}

 

返回指针的函数

原文:http://www.cnblogs.com/xiaomi5320/p/4330601.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!