[C]结构变量传递给函数

 

 

#include <stdio.h>
struct Person
{
    char name[10];
    char character[20];
    int age;
};
void display(struct Person t);
int main()
{
    struct Person man = {"jerry", "fastidious", 45}; //初始化结构变量
    display(man);
    return 0;
}

void display(struct Person t)
{
    printf("My name is %s, I'm %d years old. And my friends always complain I'm so %s.\n", t.name, t.age, t.character);
}

 

posted @ 2020-06-04 20:03  profesor  阅读(167)  评论(0编辑  收藏  举报