C语言程序设计课件第12章结构体和共用体.ppt

C语言程序设计课件第12章结构体和共用体.ppt

12.5向函数传递结构体 向函数传递结构体的单个成员 复制单个成员的内容 函数内对结构内容的修改不影响原结构 向函数传递结构体的完整结构 向函数传递结构体的首地址 struct date { int year; int month; int day; }; void func(struct date p) { p.year = 2000; p.month = 5; p.day = 22; } Before function call:1999/04/23 After function call:1999/04/23 结构体变量 作函数参数 【例12.4】 struct date { int year; int month; int day; }; void func(struct date *p) { p-year = 2000; p-month = 5; p-day = 22; } Before function call:1999/04/23 After function call:2000/05/22 结构体指针 作函数参数 指针作函数形参 实参必须为地址值 【例12.5】 struct date { int year; int month; int day; }; struct date

文档评论(0)

1亿VIP精品文档

相关文档