LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-07-2006, 07:43 PM   #1
shandy^^^
LQ Newbie
 
Registered: Jan 2006
Posts: 26

Rep: Reputation: 15
Won't work in main.c


hello everyone,

i'm just wondering why this code won't work in my main.c file. I’m using GTK+ Glade for my GUI.

I've tried to insert g_file_get_contents() in my interface.c and it is successful.

When i have it in my main.c, the compilation of the program is successful but when i run it, it would display error message like this:
The Application "project1" has quit unexpectedly.



Here is my code...Hope u can help me with this.
filename: main.c

Quote:
# include <config.h>
#endif
#include <gnome.h>
#include "interface.h"
#include "support.h"
int
main (int argc, char *argv[])
{
GtkWidget *window1;
GtkWidget *textview1;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR,
NULL);
window1 = create_window1 ();
gtk_widget_show (window1);
gboolean g_file_get_contents (const gchar *filename,
gchar **contents,
gsize *length,
GError **error);
gchar *file1 = "/var/log/messages";
gchar *contents1;
GError *err = NULL;
g_file_get_contents (file1, &contents1, NULL, &err);
g_assert ((contents1 == NULL && err != NULL) || (contents1 != NULL && err == NULL));
if (err != NULL)
{
g_assert (contents1 == NULL);
fprintf (stderr, "Unable to read file: %s\n", err->message);
g_error_free (err);
}
else
{

gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)), _(contents1), -1);

}
gtk_main();
return 0;
}
 
Old 02-07-2006, 10:36 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Sorry, can't help you with this one, but please use code-tags next time (instead of quote-tags). That way indentations will stay in and make the code more readible.
 
Old 02-07-2006, 10:42 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Have you tried any sort of debugging? Run the program through gdb after compiling it with debugging symbols? Do any messages show up on the console?
 
  


Reply


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
./main to main DDD26 Linux - Newbie 3 07-25-2005 03:09 PM
(2) Main Menu's? Isn't it, "there can be only one?" for the term "Main"? t3gah LQ Suggestions & Feedback 1 04-09-2005 09:30 AM
more main()? linuxanswer Programming 3 10-26-2003 03:06 PM
How does passing argument to main work Linh Programming 5 06-27-2003 01:08 PM
help with main.cf gruger Linux - Software 3 06-20-2003 06:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 AM.

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