I'm missing something, probably very stupid, but I have no ideas anymore, I need some help.
#include <stdio.h>
#include <stdlib.h>
typedef struct person{
char name[10];
int *age;
} PERSON;
int main(){
int i, n;
scanf("%d", &n);
PERSON *arr = (PERSON*)calloc(n, sizeof(PERSON));
for(i = 0; i < n; i++){
gets(arr[i].name);
// scanf("%d", arr[i].age);
}
for(i = 0; i < n; i++){
printf("%s", arr[i].name);
// printf("%d", arr[i]->age));
}
return 0;
}
So, I cannot enter or read the age of any structure. I need a dynamic array of persons and in each person, I need a new dynamic array as well (this is a simplified version of the original code, but the error is same).
I have commented my last tries so you can see how I tried to do it.
Error I get is [Error] invalid type argument of '->' (have 'PERSON').
gets; It has been removed from the standard, and for good reason.