Advertisement
fr1sk

vesalica

Jan 7th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #define max 50
  7. #define pokusaji 6
  8.  
  9. void stampajRec(int i, char strCrtice[60])
  10. {
  11.   int j;
  12.   for(j=0; j<i; j++)
  13.   {
  14.     printf("%c",strCrtice[j]);
  15.     printf(" ");
  16.  
  17.   }
  18. }
  19.  
  20.  
  21.  
  22. int main()
  23. {
  24.  
  25.     FILE *fp;
  26.     char str[60];
  27.     int br = 0;
  28.     char* jebem;
  29.     int i=0;
  30.     char strCrtice[60];
  31.  
  32.     srand(time(NULL)); //generise rand sa time iz pc-a
  33.  
  34.  
  35.     fp = fopen("reci.txt" , "r");
  36.     while(fgets (str, 60, fp)!=NULL )
  37.     {
  38.       br++;
  39.     }
  40.     fclose(fp);
  41.  
  42.     fp = fopen("reci.txt" , "r");
  43.     int line= rand()%br+1; //755555%5+1
  44.  
  45.     while(line)
  46.     {
  47.       jebem = fgets(str, 60, fp);
  48.       line--;
  49.     }
  50.  
  51.     i = strlen(jebem) -1;
  52.     int j=0;
  53.     for(j=0; j<i; j++)
  54.     {
  55.       strCrtice[j] = '_';
  56.  
  57.     }
  58.     strCrtice[j+1] = '\0';
  59.  
  60.     //printf("%d", i);
  61.     printf("%s", jebem);
  62.  
  63.     //stampajRec(i, strCrtice);
  64.     stampajRec(i, strCrtice);
  65.     char temp;
  66.  
  67.     printf("\n");
  68.  
  69.     for(;;)
  70.     {
  71.         scanf("%c", &temp);
  72.         printf("\n");
  73.           for(j=0; j<i; j++)
  74.           if(jebem[j]==temp)
  75.             strCrtice[j]=temp;
  76.  
  77.         if(!isspace(temp))
  78.           {
  79.             stampajRec(i, strCrtice);
  80.  
  81.           }
  82.  
  83.         printf("\n");
  84.     }
  85.  
  86.     fclose(fp);
  87.     return 0;
  88.  
  89. }
  90.  
  91.  
  92.  
  93.  
  94. /*
  95. if( fgets (str, 60, fp)!=NULL )
  96. {
  97. puts(str);
  98. }
  99. fclose(fp);
  100.  
  101. return(0);
  102. }
  103. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement