Re: Conversion functions.



On Fri, Sep 07, 2007 at 05:02:37PM +0200, Magnus Myrefors wrote:
By the way I have found out that I used 
a way of reading lines from the input-file which can cause
some problem. I read in a book that fgets(string, sizeof(string), input)
should read one line up to sizeof(string) -1 or to the first newline-
character. But when I tested I found out that that wasn't the case.

If sizeof(sizeof) does not stand for the allocated size of
the string but is meant literally, then either the book was
utter crap or you misunderstood it.  I suggest to read the
GNU libc info pages instead, the explanations there are
clear.

sizeof(a-pointer-to-char) is the size of the pointer,
usually 8 or 4.  The second fgets() argument should be the
allocated size of the string (or a smaller positive number).

Yeti

--
http://gwyddion.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]