C语言结构体变量作为函数形参

            *C语言结构体变量作为函数形参*

| 例子1


#include<stdio.h>
#include<stdbool.h>



typedef struct {
    int a;
    double b;
    bool flag;
}User;

User f(User user) {
    printf("111a is:%d\n", user.a);
    printf("111b is:%f\n", user.b);
    return user;
}


int main() {
    User user1 = {1,2.1};
    
    while (1) {
        User user = f(user1);
        user1.a = 111;
    }
    
    getchar();
    return 1;
}

猜你喜欢

转载自www.cnblogs.com/NULL-ROOT/p/10460171.html