首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c语言中的“函数部类” 与 ”函数指针类型“

2012-12-22 
c语言中的“函数类型” 与 ”函数指针类型“参考:http://light4.github.com/Linux-C/ch23s08.html/* *

c语言中的“函数类型” 与 ”函数指针类型“

参考:http://light4.github.com/Linux-C/ch23s08.html

/* * ===================================================================================== * *       Filename:  b.c * *    Description:   * *        Version:  1.0 *        Created:  09/15/2012 17:04:03 *       Revision:  none *       Compiler:  gcc * *         Author:  YOUR NAME (),  *   Organization:   * * ===================================================================================== */#include <errno.h>#include <math.h>  #include <stdio.h> #include <stdlib.h>#include <string.h>typedef void F(const char*); //define function type Ftypedef void (*PF)(const char*); //define a function pointer type PFF a;F* retPF(F* f){  // a function return a "function pointer type"    (*f)("in Ret");    return f;}    intmain ( int argc, char *argv[] ){    a("hell");    PF pF = a;printf ("\nProgram %s\n\n", argv[0] );    (*pF)("hello");    F* rP = retPF(a);    rP("rP printed");    PF pF2 = retPF(a);    pF2("PF2 printed");return EXIT_SUCCESS;}/* ----------  end of function main  ---------- */void a(const char* str){    printf("%s\n", str);}

热点排行
Bad Request.