clist and dnm.txt



hi,
i am making a clist program whic reads the lines from a file called dnm.txt and put them to clist.

firstly dnm.txt seems like that
---------dnm.txt head------------------------------------- 
Gtk+/Gnome Programlama*Ali Vardar*Papatya Yayýncýlýk*Kutuphane*00.00.0000

Yüzüklerin Efendisi*J.R.R. Tolkien*Metis Yayýnlarý*Volkan Yazýcý*00.00.0000
---------dnm.txt toe--------------------------------------

and made a program like that:
---------clist.c head-------------------------------------
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>

#include <gnome.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define MAX_UZUNLUK 255

GtkWidget *create_window1(void)
{
        GtkWidget *window1;
        GtkWidget *liste;
        static gchar *titles[] = { "No", "Kitap", "Yazar", "Yayýnevi", "Durum", "Tarih" };
        int i=0;
        int j;
        FILE *fd;
        char satir[MAX_UZUNLUK];
        gchar *row[5];

        window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_object_set_data (GTK_OBJECT (window1), "window1", window1);
        gtk_window_set_title (GTK_WINDOW (window1), _("window1"));
        gtk_window_set_default_size (GTK_WINDOW (window1), 510, 300);

        liste = gtk_clist_new_with_titles(6, titles);
        gtk_container_add(GTK_CONTAINER(window1), liste);
        
        memset(satir, 0, MAX_UZUNLUK);
        fd = fopen("dnm.txt", "r");
        
        while (fgets(satir, MAX_UZUNLUK, fd))
        {
                j=0;
                
                //No
                sprintf(row[0], "%c", ++i);
                //Adý
                while (satir[j]!='*')
                        sprintf(row[1], "%c", satir[j++]);
                j++;
                //Yazar
                while (satir[j]!='*')
                        sprintf(row[2], "%c", satir[j++]);
                j++;
                //Yayýnevi
                while (satir[j]!='*')
                        sprintf(row[3], "%c", satir[j++]);
                j++;
                //Durum
                while (satir[j]!='*')
                        sprintf(row[4], "%c", satir[j++]);
                j++;
                //Tarih
                while (satir[j]!='\n')
                        sprintf(row[5], "%c", satir[j++]);
                
                memset(satir, 0, MAX_UZUNLUK);
                
                gtk_clist_append(GTK_CLIST(liste), (char *) row);
        }
        
        fclose(fd);
        gtk_widget_show(liste);
        
        gtk_widget_show(window1);
}
---------clist.c toe--------------------------------------

i am compiling the program and running it.
but it is giving me a segmentation fault...

if you can help me it will be so good for me...
best regards

-- 
PCc0d3r
X-G3n
http://xgen.linux.org.tr/

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





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