Bonjour à tous,

je cherche à lire un fichier texte structuré (5 colonnes de nombres entiers).
Je cherche à mémoriser toutes ces valeurs dans une sorte de matrice.Or comme je ne connais pas le nombre de lignes du fichier texte, je suis parti sur une liste chainée... Voici mon code

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>

int main(int n) //, char *nomfile[])
{
FILE *Out;
int Nb_Combi=0;

struct Liste {
       int Indice;
       int Combi[5];
       int N4;
       int N3;
       int N2;
       int N1;
       
       struct Liste * psuiv;
       };
       
struct Liste *pNouveau;
struct Liste *pTete;
struct Liste *pCourant;

pTete = NULL;
pNouveau = NULL;
pCourant = NULL;

Out=fopen("resultats_num_treated.txt", "rb");

// Premier maillon = Premiere Ligne
Nb_Combi=1;
pNouveau = malloc(sizeof(struct Liste));
pTete = pNouveau;
pCourant = pTete;
pCourant->psuiv = NULL;
pCourant->Indice = Nb_Combi;
pCourant->N4=0;
pCourant->N3=0;
pCourant->N2=0;
pCourant->N1=0;

fscanf(Out, " %d %d %d %d %d\n ", pCourant->Combi[1], pCourant->Combi[2], pCourant->Combi[3], pCourant->Combi[4], pCourant->Combi[5]);
////////////////////////////////////

while (!feof(Out))) {

Nb_Combi = Nb_Combi+1;

pNouveau = malloc(sizeof(struct Liste));
pCourant->psuiv = pNouveau;
pCourant = pNouveau;
pCourant->psuiv = NULL;
pCourant->Indice = Nb_Combi;
pCourant->N4=0;
pCourant->N3=0;
pCourant->N2=0;
pCourant->N1=0;
fscanf(Out, " %d %d %d %d %d\n ", pCourant->Combi[1], pCourant->Combi[2], pCourant->Combi[3], pCourant->Combi[4], pCourant->Combi[5]);

}

 fclose(Out);
J'ai un problème sur les fscanf...

LE reste semble t il correct?

Merci de votre aide,

Alex