Re: [OT] Help with glibc memory streams
Today, exa <Eray> wrote:
[about fgets and the end-of-line]
[cut]
% cat fmemopen.c
#include <stdio.h>
int main() /* INT! GODDESSAMNIT!*/
{
char *str = "test\nbar\n"; /* \n! */
char line[80];
FILE *stream;
stream = fmemopen(str, strlen(str), "r");
while (fgets(line, 80, stream)) {
printf("Read: %s", line);
}
fclose(stream);
return 0;
}
% gcc -o fmemopen fmemopen.c && fmemopen
fmemopen.c: In function `main':
fmemopen.c:9: warning: assignment makes pointer from integer without a cast
Read: test
Read: bar
[cut]
Would you now please accept that there absolutely _has_ to be an
end-of-line character at the end of the last line in a file so that
fgets does not return NULL when reading the last line?
> Thanks,
No problem at all,
--
And Remember: Everybody would like to see package pools fix this.
Andreas Fuchs, <asf@acm.org>, <d96001@htlwrn.ac.at>, antifuchs
Reply to: