LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Won't work in main.c (https://www.linuxquestions.org/questions/programming-9/wont-work-in-main-c-412794/)

shandy^^^ 02-07-2006 07:43 PM

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;
}

Wim Sturkenboom 02-07-2006 10:36 PM

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.

Matir 02-07-2006 10:42 PM

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?


All times are GMT -5. The time now is 04:57 PM.