|
楼主 |
发表于 2020-7-2 22:30:02
|
显示全部楼层
第二个问题:
还是这段代码:
#include <stdio.h>
#define DATATYPE1 int
#define MAXSIZE 100
typedef struct
{
DATATYPE1 datas[MAXSIZE];
int last;
}SEQUENLIST;
SEQUENLIST squn1;
squn1.datas[MAXSIZE]={0,1,2,3,4};//为什么这样写不可以
main()
{
}
为什么把squn1.data放外面赋值就会报错 ,而SEQUENLIST squn1放外面就没有事的
错误是
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(55) : error C2143: syntax error : missing ';' before '.'
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(55) : error C2501: 'squn1' : missing storage-class or type specifiers
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(55) : error C2143: syntax error : missing ';' before '.'
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(55) : error C2143: syntax error : missing ';' before '{'
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(55) : error C2447: missing function header (old-style formal list?)
D:\vc\MSDev98\MyProjects\chapter2\sequenlist.cpp(74) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
|
|