Re: gtk label segmentation fault



Hi Yogesh,

please understand the C language a bit better!

i used gtk gtk_label_new( const char *str ) to create
a new label[why it needs a const char?]
because it tells you that it wont mess with the char-pointer contents you pass to the function.

below is a part of my code

const ch;
const char *cch;


ch==cch;
strcpy(ch,"i put some thing here");
label=gtk_label_new(cch);

label=gtk_label_new("i put some thing here");

1.) lesson one:
"this is a const string"

2.) a cast will do as well
char *ch;
...
label=gtk_label_new((const char *)ch);

3.) apart that code makes no sense at all
> const ch;
> const char *cch;
>
> ch==cch;
> strcpy(ch,"i put some thing here");

first line has no type
4th line is a comparission
5th line copys to unallocated space


ok, it works first time, but when the program executes
this function again it creates a segmentation fault.

also
label=gtk_label_new((const char*)ch);
doesnt work either,

this will work. you bug is elsewhere.


I get segmentation fault when, i destroy the dialog
which contain the label.


Stefan



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