Re: sprintf and clists



On Tue, 25 Jun 2002, Sean Holt wrote:

> gchar buffer[1024];
> static gchar *cclist[1];
>
> sprintf(buffer, "%d", some_dumb_int);
> cclist[0] = strdup(buffer);
> gtk_clist_append(GTK_CLIST(clist1), cclist);
>
> This is assuming you have a 1 column clist.
>

check out if the string is '\0' terminated. best initialize it after the
declaration with memset(buffer,'\0',1024);
BTW wouldn't it be enough to use a buffer of size "sizeof(int)" ?
M.

 ____                 _____
|  _ \  ___ ___  _ __| ____|
| | | |/ __/ _ \| '__|  _|
| |_| | (_| (_) | |  | |___
|____/ \___\___/|_|  |_____|





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