I am doing an exercise for fun from KandR C programming book. The program is for finding the longest line from a set of lines entered by the user and then prints it.
Her
Your error is here:
int _getline(char s[])
It means _getline
is a function returning int
getting a pointer to char
by value.
You actually want to pass that pointer (which must point to memory allocated with malloc()
or be NULL
) by reference.
That means, you need to pass a pointer to a pointer to char
.
Correcting that error will force you to correct all follow-on errors too.
Only use free
/ realloc
on NULL
resp. on pointers returned from malloc
, calloc
, realloc
or a function specified to return such a pointer.