Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


gtk_clist problem

veecoveeco Member Posts: 1
Well, I have problem with this function:
gtk_clist_append(GtkCList *clist, gchar *text[]);

I have a function that open a file and read some data from the file. The following code read data from the file.

gchar *host[ARRAY_SIZE], *temp;
/* ARRAY_SIZE is define in header file */
fscanf(fp, "%s", temp);
host[i] = g_strdup(temp);
Is there any problem with this part of coding?
This function will return the number of line read from the file. Then I need to put all the data into a Clist. So I use a for loop to do it, like the following:

gint i, ctr;
/* ctr will hold the returned value from the above function */

GtkWidget *winNew = create_winMain_new();
GtkWidget *list = lookup_widget(winNew,"winMain_new_hostlist");
gtk_clist_append(GTK_CLIST(list), &host[i]);

Well, when I run this program, I get a segmentation fault and the program terminated.

However, I try to define host[] = {“s1”, “s2”, “s3”, “s4”, “s5”, “s6”, “s7”};

gtk_clist_append(GTK_CLIST(list), &host[i]) will work.

There is one more thing I’m not understand, as I refer to gtk manual and tutorial, the gtk_clist_append should work like this (host[i] without “&”):

gtk_clist_append(GTK_CLIST(list), host[i])

but this won’t work when I tried, can anyone explain it?


  • Justin BibJustin Bib USAMember Posts: 0

    ________ [ ] free video tutorials and ebooks about [ Delphi, Visual Basic, MATLAB, Go, JavaScript, PL/SQL, C#, Swift, Assembly, Objective-C, C++, Perl, Scratch, R, Python, Ruby, Java, C, PHP, Visual Basic .NET Alice, Lisp, Lua, Hack, COBOL, Apex, Clojure, ML, SAS, Scala, Ada, Fortran, D, F#, Kotlin, Erlang, Bash, LabVIEW, Awk, Scheme, Prolog, Transact-SQL, Julia, Dart, VBScript, Crystal, ABAP, FoxPro, Logo, Rust ] ____________

Sign In or Register to comment.