GList and Combo



Hi,
I've written a function that splits text by spaces and adds them to a
GList:

GList *split_to_glist(char *s)
{
    GList *list = NULL;
    char *str = (char *) malloc(sizeof(s));
    int i, x;

    for (i = 0, x = 0; i <= strlen(s); i++, x++) {
        str[x] = s[i];
        if (str[x] == ' ' || i == strlen(s)) {
            str[x] = '\0';
            list = g_list_append(list, str);
            memset(str, 0, sizeof(str));
            x = -1;
        }
    }
    free(str);

    return list;
}

If i use the following code the combo only ever gets filled with the value
"GtkListItem".

char s[] = "Hello World";
GList *list = NULL;

list = split_to_glist(s);
gtk_combo_set_popdown_strings(GTK_COMBO(cbo), list);
            
Thanks in advance for any help.




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