Re: GString problem.



On Sun, Mar 25, 2001 at 09:54:08AM +0530, Naba Kumar wrote:
> -------------
> GString *data;
> gint count;
> 
> data = g_string_new ("");
> count = fread(buffer, sizeof (gchar), 32, fp);
> 
> /* fread () reads is a block of binary data and not a NULL terminated string */
> /* So you need to explicitly terminate it with NULL, if you want to use it as */
> /* NULL terminated string */
> buffer [count] = '\0';

Make sure to make buffer 33 bytes long then, since if it reads 32bytes you'd
just do "buffer[32] = '\0';" and .... :)  Or read in 31 bytes max ...

George

-- 
George <jirka 5z com>
   Miau miau, zikala kocicka dyz hapala do studne.
                       -- Hyta a Batul




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