下载此文档

C语言指针函数和函数指针1.docx


文档分类:IT计算机 | 页数:约9页 举报非法文档有奖
1/9
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/9 下载此文档
文档列表 文档介绍
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转载请标明出处.

非法内容举报中心
文档信息
  • 页数9
  • 收藏数0 收藏
  • 顶次数0
  • 上传人pppccc8
  • 文件大小54 KB
  • 时间2019-07-21