如何将结构的地址作为参数传递给C语言中的函数?
将结构的地址作为参数传递给函数-
结构的地址作为参数传递给函数。
它收集在指向函数标头中结构的指针中。
好处
无需浪费内存,因为无需再次创建副本
不需要返回值,因为该函数可以间接访问整个结构并对其进行处理。
示例
#include输出结果struct date{ int day; int mon; int yr; }; main (){ struct date d= {02,01,2010}; display (&d); getch (); } display (struct date *dt){ printf("day = %d\n", dt->day); printf("month = %d\n",dt->mon); printf("Year = %d",dt->yr); }
day = 2 month = 1 Year = 2010
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短