I am a student making a function that takes an file pointer, lets say stdin
and returns a struct pointer. So I'm not sure how to begin. It should return a null
pointer when EOF is encountered.
This is what I made so far:
typedef struct book
{
char *author;
char *title;
char *bookcode;
} Book;
Book *getBook(FILE *pointer)
{
Book *p;
int c;
while ((c = fgetc(pointer)) != EOF)
{
//create book
putchar (c);
}
}
return p;
}
example of input file
chris evans
hello there
as2 ss1
ashley lee
big buildings
d2a 4sa