strange Seg fault



First, you must know that this following code works perfectly, this is a clist row selection callback. I use it for testing. But there is a problem (yes...) the *y[] var isn't used, but if I delete it from the code, then I get a segmentation fault when executing this code. (very very strange, it seg fault as well after rebooting)

But I found another relation, if I delete the sprintf function and the *y[] var, then there is no more seg fault... So I deduce that sprintf func without *y[] unused var makes a seg fault.

but I need to use sprintf func (cause I haven't itoa() func) and I don't want this *y[] ghost var in my project... does somebody can find where could there be a problem.. thnx

gboolean Callback_RowSelect(GtkWidget *w, gint lig, gint col, GdkEvent *ev, gpointer d)
{
	gchar *y[3];
	gchar *t[3];
	gint x=0;
	
	GtkWidget *dList = gtk_object_get_data(GTK_OBJECT(EditWin),"pList");

	gtk_clist_clear(GTK_CLIST(dList));

	while(MyStruct[x].pNum)
	{
		sprintf(t[0],"%i",MyStruct[x].pNum); //converts a gint into gchar
		t[1]=MyStruct[x].pName;
		t[2]=MyStruct[x].pPos;

		gtk_clist_append(GTK_CLIST(dList),t);
		x++;
	}	
	return TRUE;
}



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