[Glade-users] gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(fs));



On Tue, 03 Jun 2014 20:53:16 -0400
Ian Chapman <ichapman at videotron.ca> wrote:

    I do not understand why I'm getting a segment fault from strcpy 
using cName_pt in the above code.  I can printf using cName_pt and it 
prints the file that I selected using the glade gtkfilechooserwidget.  I 
must be doing something silly, I hope that someone can see what it is?  

How is fileselected declared? If as  char *fileselected, then you have to
allocate memory to fileselected first. It will work with a short string
like 1234, but not if the string is longer than 4 bytes or so. Remember
*fileselection is just a pointer - it doesn't have space yet. (you could
use strdup, which _does_ allocate memory ->  fileselected = strdup(...)

If defined as char fileselected[100] (or so) you might be exceeding
the [100] limit.

John




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