Bonjour,
J'ai un problème sous GTK et je n'arrive pas à le résoudre...
Je voudrais charger des données d'un fichier texte et les mettre dans une liste. Cependant il y des restrictions.
Voici le fichier texte :
Info/Nom_de_l'information,Info/Nom_de_l'information/Info/Nom_de_l'information3
Ce que je voudrais, c'est charger seulement le nom de l'information et la mettre dans une liste. Voilà mon bout de code :
Voilà, ça ne marche pas :'( J'aurais besoin de vos lumières.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 char *Info; char Lettre; fp_info=fopen("informations.txt","r"); if (fp_info == NULL){ perror("Erreur"); exit(0); } while (!feof(fp_info)) { Categ = (char *) calloc(1,sizeof(char)); k=1; while (strcmp(Lettre,"/") != 0){ Lettre = (char)fgetc(fp_info); strcat(Info,&Lettre); k++; Info = (char *) realloc(Info, k*sizeof(char)); } if (strncmp(Info,"Info/",5) == 0){ list = g_list_append(list, g_strdup_printf("%s",&Info)); } free(Info); } fclose(fp_info);
Merci d'avance.
Partager