Commit 67e3cd7b40e76803fed25baaced77a23be78352f
1 parent
813e29bb
programme de recuperation de fichiers
Showing
1 changed file
with
113 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,113 @@ | @@ -0,0 +1,113 @@ | ||
1 | +//By Bianca and Mathis | ||
2 | + | ||
3 | +//Ce programme permet : | ||
4 | +//De recupérer les données d'un fichier csv et de les stokers dans un tableau de char (toutes les virgules). | ||
5 | + | ||
6 | + | ||
7 | +#include <stdio.h> | ||
8 | +#include <stdlib.h> | ||
9 | +#include <stdbool.h> | ||
10 | +#include <string.h> | ||
11 | +#include <ctype.h> | ||
12 | + | ||
13 | + | ||
14 | +/* | ||
15 | +//fonction d'affichage | ||
16 | +void affiche_header_top50() | ||
17 | +{ | ||
18 | + printf("Index nom prenom score"); | ||
19 | +} | ||
20 | + | ||
21 | +void affiche_header_recherche() | ||
22 | +{ | ||
23 | + printf("athId nom prenom gender age taille poids score18.1 score18.2 score 18.2a score18.3 score18.4 score18.5"); | ||
24 | +} | ||
25 | + | ||
26 | +void affiche_top50(Personne P, int i) | ||
27 | +{ | ||
28 | + printf("%d %s %s %d", i , P.lastName, P.firstName, P.overallScrore); | ||
29 | +} | ||
30 | + | ||
31 | +void affiche_recherche(Personne P) | ||
32 | +{ | ||
33 | + 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); | ||
34 | +} | ||
35 | +*/ | ||
36 | + | ||
37 | +#define DELIM "," | ||
38 | +#define BUFF_SIZE 128 | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | +void recup_fichier(char *f_lecture) | ||
43 | +{ | ||
44 | + FILE * file = NULL; | ||
45 | + char buff [BUFF_SIZE]; | ||
46 | + | ||
47 | + file = fopen (f_lecture, "r"); | ||
48 | + | ||
49 | + if (file != NULL) | ||
50 | + { | ||
51 | + if ((fgets (buff, BUFF_SIZE, file)) != NULL) | ||
52 | + { | ||
53 | + printf("%s", buff); | ||
54 | + } | ||
55 | + | ||
56 | + fclose (file); | ||
57 | + } | ||
58 | +} | ||
59 | + | ||
60 | + | ||
61 | +/* | ||
62 | +char **str_split (char *s, const char *ct) | ||
63 | +{ | ||
64 | + char **tab = NULL; | ||
65 | + | ||
66 | + if (s != NULL && ct != NULL) | ||
67 | + { | ||
68 | + int i; | ||
69 | + char *cs = NULL; | ||
70 | + size_t size = 1; | ||
71 | + | ||
72 | + | ||
73 | + for (i = 0; (cs = strtok (s, ct)); i++) | ||
74 | + { | ||
75 | + if (size <= i + 1) | ||
76 | + { | ||
77 | + void *tmp = NULL; | ||
78 | + | ||
79 | + | ||
80 | + size <<= 1; | ||
81 | + tmp = realloc (tab, sizeof (*tab) * size); | ||
82 | + if (tmp != NULL) | ||
83 | + { | ||
84 | + tab = tmp; | ||
85 | + } | ||
86 | + else | ||
87 | + { | ||
88 | + fprintf (stderr, "Memoire insuffisante\n"); | ||
89 | + free (tab); | ||
90 | + tab = NULL; | ||
91 | + exit (EXIT_FAILURE); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
95 | + tab[i] = cs; | ||
96 | + s = NULL; | ||
97 | + } | ||
98 | + tab[i] = NULL; | ||
99 | + } | ||
100 | + return tab; | ||
101 | +} | ||
102 | +*/ | ||
103 | + | ||
104 | + | ||
105 | +int main (int argc, char * argv[]) | ||
106 | +{ | ||
107 | + char **ligne = NULL; | ||
108 | + | ||
109 | + recup_fichier(argv[1]); | ||
110 | + //printf("%s ", *ligne); | ||
111 | + | ||
112 | + return EXIT_SUCCESS; | ||
113 | +} |