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
| typedef struct MOTS MOTS;
struct MOTS
{
int id;
char champs[45];
};
typedef struct BDD BDD;
struct BDD
{
MOTS *mot;
};
int ligne= ouvrir_fichier("null.csv" ,texte);//recupération du nombre de lignes durant l'ouverture du fichier
int cat = comptage_categorie(texte);
BDD *structure = (BDD *)malloc (cat*sizeof(BDD));
int i,j;
for (i=0; i<cat; i++)
{
for(j=0;j<ligne;j++){
structure[i].mot = (MOTS *)malloc (sizeof(MOTS));
}
}
j=0;
int k=0,a=0,l=0;
while(texte[a] != '\n')//boucle pour ignorer la première ligne
{
a++;
}
for(i=a+1;i<strlen(texte);i++)
{
if(isalnum(texte[i]))
{
structure[k].mot[l].champs[j] = texte[i];//si le caractère est une lettre ou un chiffre il est stocké
j++;
}
else if(texte[i] == ',')
{
j=0;//si c'est une virgule, on change de catégorie
k++;
}
else if(texte[i]== '\n')
{
l++;// si c'est un retour à la ligne changement de ligne et retour à la premiere catégorie
j=0;
k=0;
}
} |
Partager