Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ouverture_motherboard(Motherboard motherboard_array[18]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("MOTHERBOARD.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our motherboard array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Motherboard motherboard;
- // copy the content of each properties in the structure
- strcpy(motherboard.marque, array[0]);
- strcpy(motherboard.modele, array[1]);
- strcpy(motherboard.socket_proc, array[2]);
- strcpy(motherboard.nbr_socket, array[3]);
- strcpy(motherboard.nbr_ram, array[4]);
- strcpy(motherboard.ver_ram, array[5]);
- strcpy(motherboard.nbr_pci, array[6]);
- strcpy(motherboard.nbr_ide, array[7]);
- strcpy(motherboard.nbr_sata, array[8]);
- strcpy(motherboard.nbr_usb, array[9]);
- strcpy(motherboard.nbr_vga, array[10]);
- strcpy(motherboard.nbr_reseau, array[11]);
- strcpy(motherboard.format, array[12]);
- strcpy(motherboard.usp, array[13]);
- strcpy(motherboard.fiab, array[14]);
- strcpy(motherboard.restrict, array[15]);
- strcpy(motherboard.prix, array[16]);
- strcpy(motherboard.conso_elec, array[17]);
- strcpy(motherboard.overclock, array[18]);
- // add this structure in the array defined previousment
- motherboard_array[cpt++] = motherboard;
- }
- fclose(fichier);
- }
- void ouverture_graphics(Graphics graphics_array[12]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("GRAPHICS.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our graphics array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Graphics graphics;
- // copy the content of each properties in the structure
- strcpy(graphics.marque, array[0]);
- strcpy(graphics.modele, array[1]);
- strcpy(graphics.nbr_vga, array[2]);
- strcpy(graphics.nbr_dvi, array[3]);
- strcpy(graphics.nbr_hdmi, array[4]);
- strcpy(graphics.nbr_minidp, array[5]);
- strcpy(graphics.usp, array[6]);
- strcpy(graphics.fiab, array[7]);
- strcpy(graphics.restrict, array[8]);
- strcpy(graphics.prix, array[9]);
- strcpy(graphics.perf, array[10]);
- strcpy(graphics.conso_elec, array[11]);
- strcpy(graphics.overclock, array[12]);
- // add this structure in the array defined previousment
- graphics_array[cpt++] = graphics;
- }
- fclose(fichier);
- }
- void ouverture_hdd(Hdd hdd_array[9]){
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("HDD.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our hdd array to store all lines in CSV file
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- Hdd hdd;
- // copy the content of each properties in the structure
- strcpy(hdd.marque, array[0]);
- strcpy(hdd.modele, array[1]);
- strcpy(hdd.capa, array[2]);
- strcpy(hdd.port, array[3]);
- strcpy(hdd.usp, array[4]);
- strcpy(hdd.fiab, array[5]);
- strcpy(hdd.restrict, array[6]);
- strcpy(hdd.prix, array[7]);
- strcpy(hdd.perf, array[8]);
- strcpy(hdd.conso_elec, array[9]);
- // add this structure in the array defined previousment
- hdd_array[cpt++] = hdd;
- }
- fclose(fichier);
- }
- void ouverture_Ecran()
- {
- FILE* fichier = NULL;
- char caractere[TAILLE_MAX];
- fichier = fopen("ECRAN.csv", "r");
- if(fichier != NULL)
- {
- }
- else
- {
- printf("impossible d'ouvrir le fichier");
- }
- // Define our proco array to store all lines in CSV file
- caracEcran ecran_array[5];
- int cpt = 0;
- // get the whole line for each
- while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
- {
- // Get all the strings delimited by a ';'
- char ** array = str_split(caractere, ';');
- // Define a new structure
- caracEcran ecran;
- // copy the content of each properties in the structure
- strcpy(ecran.marque, array[0]);
- strcpy(ecran.modele, array[1]);
- strcpy(ecran.taille, array[2]);
- strcpy(ecran.resolMax, array[3]);
- strcpy(ecran.typePort, array[4]);
- strcpy(ecran.uniqueSellingPoint, array[5]);
- strcpy(ecran.restriction, array[6]);
- strcpy(ecran.prix, array[7]);
- strcpy(ecran.indiceDePerf, array[8]);
- strcpy(ecran.consoElec, array[9]);
- // add this structure in the array defined previousment
- ecran_array[cpt++] = ecran;
- }
- fclose(fichier);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement