C语言指针函数和函数指针1.docx・Two,functionpointerThepointertothefunctioncontainstheaddressofthefunction,:Thetypespecifier(*functionname)(parameters)Infact,thiscannotbecalledafunctionname・Itshouldbecalledthevariablenameofthepointer・Thisspecialpointerpointstoafunctionthatreturnstheintegervalue・・Ifthereisnoparentheses,:Void(*fptr)();Assigningtheaddressofafunctiontoafunctionpointercantakethefollowingtwoforms:Fptr=&Function;Fptr二Function;Theaddressoperatorisnotrequiredbecauseonlyafunctionidentifierrepresentsitsaddress,andifitisafunctioncall,itmustincludeaparametertableenclosedinparentheses・Thefollowingtwowayscanbeusedtocallfunctionsthroughpointers:X二(*fptr)();X=fptr();Thesecondformatslooklikefunctioncalls・However,someprogrammersprefertousethefirstformatbecauseitexplicitlystatesthatthefunctioniscalledthroughpointersratherthanfunctionnames・Here'sanexample:Void(*funcp)();Void,FileFunc(),EditFunc();(main)Funcp二FileFunc;(*funcp)();Funcp=EditFunc;(*funcp)();Void,FileFunc()Printf(\〃F订eFunc\\n\〃);Void,EditFunc()Printf(\zzEditFunc\\n\zz);Programoutputas:FileFunc
C语言指针函数和函数指针1 来自淘豆网www.taodocs.com转载请标明出处.