combo widget list



Trying to fill a combo box widget with labels from a file, find the
error? The first part of the line is extracted as label.

int fgk_ReadAircrafts(char *flyfile)
{
        FILE *tmp;
        char str[64];
        char *ipos;
        char token[32];
        GString *tok;
        
        if((tmp=fopen(flyfile,"r"))!=NULL) {
                while(!feof(tmp)) {
                        fgets(str,sizeof(str)-1,tmp);
                        ipos=strchr(str,' ');
                        
                        if (ipos!=NULL) {
                                strncpy(token,str,ipos-str);
                                token[ipos-str]=0;
                                tok = g_string_new(token);
                                combo_aircraft_list=g_list_append (combo_aircraft_list, tok);
                        }
                }       
                fclose(tmp);
        } else {
                return(-1);
        }       
        return(0);      
}       



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