Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 10-04-2010, 06:54 PM   #1
Registered: Mar 2010
Distribution: Arch Linux, FreeBSD
Posts: 31

Rep: Reputation: 0
C GTK+: String returned by gtk_file_chooser_get_filename gives segmentation fault

My program gives a segmentation fault when fputs 'ing the filename. Why is that? ( fopen works like a charm )

void change_port ( void )
    if ( port != NULL )    fclose(port);    //    If it is already open close it

    char *fname = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(port_select));


    port = fopen(fname, "r+");

    if ( port == NULL )
        error("Error Opening Port: ");

void error ( char *msg )
    fputs(msg, stderr);

Old 10-05-2010, 05:59 AM   #2
LQ Newbie
Registered: Aug 2010
Posts: 2

Rep: Reputation: 0
check fname for NULL
Old 10-05-2010, 04:50 PM   #3
Registered: Mar 2010
Distribution: Arch Linux, FreeBSD
Posts: 31

Original Poster
Rep: Reputation: 0
Thank you. Now is feel dumb. I have solved why this is happening. Thank you very much.


gtk, gtk+, segfault, segmentation fault

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ALL GTK APPS do a segmentation fault when X win in monochrome smeezekitty Linux - Newbie 10 10-27-2009 01:25 AM
Segmentation Fault - Gtk Static App boogy Programming 2 01-22-2007 06:44 AM
Segmentation fault cause by String type nelnel Programming 2 08-23-2005 09:46 PM
dpkg returned an error code (1) Segmentation fault questionman Debian 6 11-02-2004 12:04 AM
segmentation fault with my Gtk Application jaganmolleti Programming 1 03-18-2003 11:05 AM

All times are GMT -5. The time now is 05:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration