Advertisement
Guest User

Untitled

a guest
May 25th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.54 KB | None | 0 0
  1. void ouverture_motherboard(Motherboard motherboard_array[18]){
  2.     FILE* fichier = NULL;
  3.     char caractere[TAILLE_MAX];
  4.  
  5.     fichier = fopen("MOTHERBOARD.csv", "r");
  6.     if(fichier != NULL)
  7.     {
  8.     }
  9.     else
  10.     {
  11.         printf("impossible d'ouvrir le fichier");
  12.     }
  13.  
  14.     // Define our motherboard array to store all lines in CSV file
  15.  
  16.     int cpt = 0;
  17.     // get the whole line for each
  18.     while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  19.     {
  20.         // Get all the strings delimited by a ';'
  21.         char ** array = str_split(caractere, ';');
  22.  
  23.         // Define a new structure
  24.         Motherboard motherboard;
  25.  
  26.         // copy the content of each properties in the structure
  27.         strcpy(motherboard.marque, array[0]);
  28.         strcpy(motherboard.modele, array[1]);
  29.         strcpy(motherboard.socket_proc, array[2]);
  30.         strcpy(motherboard.nbr_socket, array[3]);
  31.         strcpy(motherboard.nbr_ram, array[4]);
  32.         strcpy(motherboard.ver_ram, array[5]);
  33.         strcpy(motherboard.nbr_pci, array[6]);
  34.         strcpy(motherboard.nbr_ide, array[7]);
  35.         strcpy(motherboard.nbr_sata, array[8]);
  36.         strcpy(motherboard.nbr_usb, array[9]);
  37.         strcpy(motherboard.nbr_vga, array[10]);
  38.         strcpy(motherboard.nbr_reseau, array[11]);
  39.         strcpy(motherboard.format, array[12]);
  40.         strcpy(motherboard.usp, array[13]);
  41.         strcpy(motherboard.fiab, array[14]);
  42.         strcpy(motherboard.restrict, array[15]);
  43.         strcpy(motherboard.prix, array[16]);
  44.         strcpy(motherboard.conso_elec, array[17]);
  45.         strcpy(motherboard.overclock, array[18]);
  46.  
  47.         // add this structure in the array defined previousment
  48.         motherboard_array[cpt++] = motherboard;
  49.     }
  50.  
  51.     fclose(fichier);
  52. }
  53.  
  54. void ouverture_graphics(Graphics graphics_array[12]){
  55.     FILE* fichier = NULL;
  56.     char caractere[TAILLE_MAX];
  57.  
  58.     fichier = fopen("GRAPHICS.csv", "r");
  59.     if(fichier != NULL)
  60.     {
  61.     }
  62.     else
  63.     {
  64.         printf("impossible d'ouvrir le fichier");
  65.     }
  66.  
  67.     // Define our graphics array to store all lines in CSV file
  68.  
  69.     int cpt = 0;
  70.     // get the whole line for each
  71.     while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  72.     {
  73.         // Get all the strings delimited by a ';'
  74.         char ** array = str_split(caractere, ';');
  75.  
  76.         // Define a new structure
  77.         Graphics graphics;
  78.  
  79.         // copy the content of each properties in the structure
  80.         strcpy(graphics.marque, array[0]);
  81.         strcpy(graphics.modele, array[1]);
  82.         strcpy(graphics.nbr_vga, array[2]);
  83.         strcpy(graphics.nbr_dvi, array[3]);
  84.         strcpy(graphics.nbr_hdmi, array[4]);
  85.         strcpy(graphics.nbr_minidp, array[5]);
  86.         strcpy(graphics.usp, array[6]);
  87.         strcpy(graphics.fiab, array[7]);
  88.         strcpy(graphics.restrict, array[8]);
  89.         strcpy(graphics.prix, array[9]);
  90.         strcpy(graphics.perf, array[10]);
  91.         strcpy(graphics.conso_elec, array[11]);
  92.         strcpy(graphics.overclock, array[12]);
  93.  
  94.         // add this structure in the array defined previousment
  95.         graphics_array[cpt++] = graphics;
  96.     }
  97.  
  98.     fclose(fichier);
  99. }
  100.  
  101. void ouverture_hdd(Hdd hdd_array[9]){
  102.     FILE* fichier = NULL;
  103.     char caractere[TAILLE_MAX];
  104.  
  105.     fichier = fopen("HDD.csv", "r");
  106.     if(fichier != NULL)
  107.     {
  108.     }
  109.     else
  110.     {
  111.         printf("impossible d'ouvrir le fichier");
  112.     }
  113.  
  114.     // Define our hdd array to store all lines in CSV file
  115.  
  116.     int cpt = 0;
  117.     // get the whole line for each
  118.     while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  119.     {
  120.         // Get all the strings delimited by a ';'
  121.         char ** array = str_split(caractere, ';');
  122.  
  123.         // Define a new structure
  124.         Hdd hdd;
  125.  
  126.         // copy the content of each properties in the structure
  127.         strcpy(hdd.marque, array[0]);
  128.         strcpy(hdd.modele, array[1]);
  129.         strcpy(hdd.capa, array[2]);
  130.         strcpy(hdd.port, array[3]);
  131.         strcpy(hdd.usp, array[4]);
  132.         strcpy(hdd.fiab, array[5]);
  133.         strcpy(hdd.restrict, array[6]);
  134.         strcpy(hdd.prix, array[7]);
  135.         strcpy(hdd.perf, array[8]);
  136.         strcpy(hdd.conso_elec, array[9]);
  137.  
  138.         // add this structure in the array defined previousment
  139.         hdd_array[cpt++] = hdd;
  140.     }
  141.  
  142.     fclose(fichier);
  143. }
  144.  
  145. void ouverture_Ecran()
  146. {
  147.     FILE* fichier = NULL;
  148.     char caractere[TAILLE_MAX];
  149.  
  150.     fichier = fopen("ECRAN.csv", "r");
  151.     if(fichier != NULL)
  152.     {
  153.     }
  154.     else
  155.     {
  156.         printf("impossible d'ouvrir le fichier");
  157.     }
  158.  
  159.     // Define our proco array to store all lines in CSV file
  160.     caracEcran ecran_array[5];
  161.  
  162.     int cpt = 0;
  163.     // get the whole line for each
  164.     while(fgets(caractere, TAILLE_MAX, fichier) != NULL)
  165.     {
  166.         // Get all the strings delimited by a ';'
  167.         char ** array = str_split(caractere, ';');
  168.  
  169.         // Define a new structure
  170.         caracEcran ecran;
  171.  
  172.         // copy the content of each properties in the structure
  173.         strcpy(ecran.marque, array[0]);
  174.         strcpy(ecran.modele, array[1]);
  175.         strcpy(ecran.taille, array[2]);
  176.         strcpy(ecran.resolMax, array[3]);
  177.         strcpy(ecran.typePort, array[4]);
  178.         strcpy(ecran.uniqueSellingPoint, array[5]);
  179.         strcpy(ecran.restriction, array[6]);
  180.         strcpy(ecran.prix, array[7]);
  181.         strcpy(ecran.indiceDePerf, array[8]);
  182.         strcpy(ecran.consoElec, array[9]);
  183.  
  184.  
  185.         // add this structure in the array defined previousment
  186.         ecran_array[cpt++] = ecran;
  187.     }
  188.  
  189.     fclose(fichier);
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement