如何给结构体成员赋值问题
#include <stdio.h>
int main()
{
struct student{
char name[20];
int score;
};
struct student st={"John",100},*ptr;
// student st={"John",100},*ptr;
ptr=&st;
printf("ptr->name=%s\n",ptr->name);
return 0;
}
用gcc 4.2编译器无法编译:// student st={"John",100},*ptr;,但是用VS08却可以, 是不是编译器问题?
另外用gcc 4.2也无法这样编译:st={"John",100};是不是只能这样赋值:struct student st={"John",100};或者:st.name="John";st.score=100; ?