diff --git a/src/recup_fichier2.c b/src/recup_fichier2.c new file mode 100644 index 0000000..27f757c --- /dev/null +++ b/src/recup_fichier2.c @@ -0,0 +1,113 @@ +//By Bianca and Mathis + +//Ce programme permet : +//De recupérer les données d'un fichier csv et de les stokers dans un tableau de char (toutes les virgules). + + +#include +#include +#include +#include +#include + + +/* +//fonction d'affichage +void affiche_header_top50() +{ + printf("Index nom prenom score"); +} + +void affiche_header_recherche() +{ + printf("athId nom prenom gender age taille poids score18.1 score18.2 score 18.2a score18.3 score18.4 score18.5"); +} + +void affiche_top50(Personne P, int i) +{ + printf("%d %s %s %d", i , P.lastName, P.firstName, P.overallScrore); +} + +void affiche_recherche(Personne P) +{ + printf("%d %s %s %c %d %s %s %d %d %d %d %d %d", P.athId, P.lastName, P.firstName, P.gender, P.age, P.height, P.weight, P.score18_1, P.score18_2, P.score18_2a, P.score18_3, P.score18_4, P.score18_5); +} +*/ + +#define DELIM "," +#define BUFF_SIZE 128 + + + +void recup_fichier(char *f_lecture) +{ + FILE * file = NULL; + char buff [BUFF_SIZE]; + + file = fopen (f_lecture, "r"); + + if (file != NULL) + { + if ((fgets (buff, BUFF_SIZE, file)) != NULL) + { + printf("%s", buff); + } + + fclose (file); + } +} + + +/* +char **str_split (char *s, const char *ct) +{ + char **tab = NULL; + + if (s != NULL && ct != NULL) + { + int i; + char *cs = NULL; + size_t size = 1; + + + for (i = 0; (cs = strtok (s, ct)); i++) + { + if (size <= i + 1) + { + void *tmp = NULL; + + + size <<= 1; + tmp = realloc (tab, sizeof (*tab) * size); + if (tmp != NULL) + { + tab = tmp; + } + else + { + fprintf (stderr, "Memoire insuffisante\n"); + free (tab); + tab = NULL; + exit (EXIT_FAILURE); + } + } + + tab[i] = cs; + s = NULL; + } + tab[i] = NULL; + } + return tab; +} +*/ + + +int main (int argc, char * argv[]) +{ + char **ligne = NULL; + + recup_fichier(argv[1]); + //printf("%s ", *ligne); + + return EXIT_SUCCESS; +} -- libgit2 0.21.2