当我赋值这样它亘古不变的工作s.rollno分配结构变量的值
#include<stdio.h>
struct student{
int rollno;
int marks;
}s ;
s.rollno = 2;
int main(){
printf("%d",s.rollno);
}
但如果我分配值主要以s.rollno它的工作原理
#include<stdio.h>
struct student{
int rollno;
int marks;
}s ;
int main(){
s.rollno = 2;
printf("%d",s.rollno);
}
这与结构无关。你不能'诠释我;我= 2;'功能之外。除了声明事物之外,你什么也做不了。 – chris
你不能在任何函数范围外有这样的代码。 –
阅读答案在http://stackoverflow.com/questions/17363664/cant-use-structure-in-global-scope –