Code:
#include <stdio.h>
#include <stdlib.h>
struct Player{
int x;
};
int main(void){
int i,j;
struct Player **A;
struct Player data; // line 11
A=(data **)calloc(5, sizeof(data *));
for(i=0; i<5; i++){
A[i]=(data *)calloc(3, sizeof(data));
}
for(i=0; i<5; i++){
for(j=0; j<3; j++){
struct Player[i].x=4; // line 21
//data[i].x = 4; // line 22
}
}
for(i=0; i<5; i++){
printf("\n");
for(j=0; j<3; j++){
printf("Array[%d][%d]: %d", i, j, data[i].x);
}
}
return 0;
}
My problem is in lines: 11, 21, 22...(in these lines i am not sure if the code is right...it's my second day in structs...)
I'm not sure though if the rest is ok...
output:
vasileios@vasileios-laptop:~/desktop$ gcc askisi1.c
askisi1.c: In function ‘main’:
askisi1.c:13: error: expected expression before ‘)’ token
askisi1.c:15: error: expected expression before ‘)’ token
askisi1.c:20: error: expected identifier or ‘(’ before ‘[’ token
askisi1.c:28: error: subscripted value is neither array nor pointer