Initialize/reset struct to zero/null

前端 未结 9 1834
攒了一身酷
攒了一身酷 2020-11-27 10:28
struct x {
    char a[10];
    char b[20];
    int i;
    char *c;
    char *d[10];
};

I am filling this struct and then using the values. On the n

9条回答
  •  醉酒成梦
    2020-11-27 11:05

    I believe you can just assign the empty set ({}) to your variable.

    struct x instance;
    
    for(i = 0; i < n; i++) {
        instance = {};
        /* Do Calculations */
    }
    

提交回复
热议问题