标题: 《The C Programming language》结构体赋值的问题? [打印本页] 作者: xiaowh00 时间: 2012-06-26 09:49 标题: 《The C Programming language》结构体赋值的问题? #include <stdio.h>
main()
{
struct point
{
int x;
int y;
};
struct point x1;
x1={320,200};
printf("%d %d\n",x1.y,x1.x);
}
gcc 编译后提示:
6.1.c: In function ‘main’:
6.1.c:13: error: expected expression before ‘{’ token
而用x1.x=320;x1.y=200赋值就正常
书《The C Programming language》上说: A structure can be initialized by following its definition with a list of initializers, each a constant expression, for the members:
struct maxpt = { 320, 200 };
求指导?