您的位置:首页 > 其它

struct 中部分变量赋值

2011-01-15 19:16 190 查看
C 语言中对struct中部分变量命名,见到变量名中带 . 不要惊讶——C变量名是不允许有 . 的

#include <stdio.h>

int main(int argc, char *argv[])
{
struct s {
int a;
int b;
int c;
};

struct s test = {
.b = 6,
.c = 7,
};

printf("struct is %d, %d, %d/n", test.a, test.b, test.c);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: