Reputation: 5476
I have made the following code in 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 | }
The problem is that this code does not compile. The errors I got are:
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
Upvotes: 1
Views: 315
Reputation: 320777
It appears to be a bug in the compiler you are using. I can only suggest adding a tag to your struct type
typedef struct car {
int cod;
} car;
It won't require any changes in the rest of the code, but might help it to compile.
Upvotes: 3