我在 C 中编写了以下代码:
1 | #include <stdio.h>
2 | #include <stdlib.h>
3 | #include <time.h>
4 |
5 | typedef struct{
6 | int cod;
7 | } car;
8 |
9 | int main(int argc, char *argv[])
10 | {
11 | int i;
12 | car store[10];
13 | srand(time(NULL));
14 | for (i=0;i<10;i++){
15 | store[i].cod=rand();
16 | }
17 | system("PAUSE");
18 | return 0;
19 | }
问题是这段代码无法编译。我得到的错误是:
7 C:\Dev-Cpp\main.c [Warning] useless keyword or type name in empty declaration
7 C:\Dev-Cpp\main.c [Warning] unnamed struct/union that defines no instances
15 C:\Dev-Cpp\main.c request for member `cod' in something not a structure or union