Question regarding fgets and new lines



I need to read in a comma separated file, and for this I was going to
use fgets. I was reading about it at http://www.cplusplus.com/ref/ and
I noticed that the document said:

"Reads characters from stream and stores them in string until (num -1)
characters have been read or a newline or EOF character is reached,
whichever comes first."

My question is that if it stops at a new line character (LF?) then how
does one read a file with multiple new line characters?

Another question. The syntax is:

char * fgets (char * string , int num , FILE * stream);

but you have to allot a size for the string before this. Would you just
use the same num as used in the fgets? So char stringexample[num] ?

.



Relevant Pages

  • Re: Question regarding fgets and new lines
    ... "Reads characters from stream and stores them in string until (num -1) ... use the same num as used in the fgets? ...
    (comp.lang.c)
  • Re: Is this string input function safe?
    ... return a pointer to mallocated memory holding one input string, ... See my comment after your call to fgets. ... char* malloc_getstr ... before any characters are read, then the ...
    (comp.lang.c)
  • Regarding: fgets() replacement
    ... > shortcomings of fgets(). ... Your algorithm can end up calling realloc O) times. ... set of characters read (with the exception of the last one that might ... Paul Hsieh ...
    (comp.lang.c)
  • Re: Is C99 the final C? (some suggestions)
    ... fgets was designed to read text lines into a string. ... that fgetsdoes not ignore embedded null characters in text files. ... and puts it in the buffer nominated. ...
    (comp.lang.c)
  • Re: [OT] Re: OT: Gawk match() and numbers in scientific notation
    ... collating sequences, so that when someone comes asking "why doesn't sort ... The script is far away from being smart, efficient, or anything like that, but it seems to work with Unicode-aware locales. ... The example shows that in da_DK.UTF-8 locale, the range expands to less characters than in en_GB locales. ... num = sprintf ...
    (comp.lang.awk)