I've read about it and I mostly get it, but this situation confused me a bit. Why don't we use arrow operator ->
in scanf
? I understand that dot is used for objects and arrow for pointers but here, g
is a pointer to structure.
DOCUMENT *take(int *pn){
DOCUMENT *g;
printf("How much documents? ");
scanf("%d", pn);
g = (DOCUMENT *)calloc(*pn, sizeof(DOCUMENT));
for (int i = 0; i < *pn; i++)
{
printf("Type in author, name of document and number of pages: ");
scanf("%s %s %d", g[i].author, g[i].name, &g[i].s );
}
return g;
}