Advertisement
Guest User

Untitled

a guest
May 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <time.h>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.     FILE* fichier = NULL;
  9.     char pioche[100] = "AAAAAAAAABBCCDDDEEEEEEEEEEEEEEEFFGGHHIIIIIIIIJKLLLLLMMMNNNNNNOOOOOOPPQRRRRRRSSSSSSTTTTTTUUUUUUVVWXYZ";
  10.     char tirage[15];
  11.     size_t len = strlen(tirage);
  12.     char newt[15];
  13.     char mot[16];
  14.     char *ptr_pos;
  15.     int i,j;
  16.  
  17.     for (j=0; j < 10; j++) {
  18.         srand(time(NULL));
  19.         int alea = rand() % strlen(pioche);
  20.         tirage[j] = pioche[alea];
  21.     }
  22.     tirage[10] = '\0';
  23.     printf("%s\n", tirage);
  24.  
  25.     fichier = fopen("/home/kiange/public_html/bac/ODS5.txt", "r");
  26.  
  27.     if (fichier != NULL)
  28.     {
  29.         while (fgets(mot, 20, fichier) != NULL)
  30.         {
  31.               size_t len_mot = strlen(mot) - 1;
  32.               if (len_mot <= len)
  33.               {
  34.                     strcpy(newt,tirage);
  35.                     for (i = 0; i < len_mot; i++)
  36.                     {
  37.                           ptr_pos = strchr(newt,mot[i]);
  38.                           if (ptr_pos != NULL)
  39.                                 newt[ptr_pos - newt] = '-';
  40.                           else
  41.                                 break;
  42.                     }
  43.                     if (i == len_mot) {}
  44.                           //printf ("%s", mot);
  45.               }
  46.         }
  47.         fclose(fichier);
  48.     }
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement