Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. #include <time.h>
  5.  
  6. struct FtpFile {
  7.     const char *filename;
  8.     FILE *stream;
  9. };
  10. char* pass_string();
  11.  
  12. void CheckAndInsertLetter(char* word, char guess);
  13.  
  14.  
  15.  
  16. int main(void)
  17. {
  18.    
  19.     char guess;
  20.     char *c = pass_string();
  21.     printf("%c", c);
  22.     printf("Enter guess: ");
  23.     scanf("%c", &guess);
  24.     return 0;
  25. }
  26.  
  27. void CheckAndInsertLetter(char* word, char guess) {
  28.  
  29.  
  30.  
  31.  
  32. }
  33.  
  34. char* pass_string() //keep square brackets in signature
  35. {
  36.     char availableWords[23206][8];
  37.     FILE *fptr;
  38.     int counter = 0;
  39.     fptr = fopen("words.txt", "r+");
  40.     char buffer[8];
  41.     while (fgets(buffer, sizeof buffer, fptr) != NULL)
  42.     {
  43.         //printf("%s", buffer);
  44.         if (buffer[0] != '\n') {
  45.             availableWords[counter][0] = buffer[0];
  46.             availableWords[counter][1] = buffer[1];
  47.             availableWords[counter][2] = buffer[2];
  48.             availableWords[counter][3] = buffer[3];
  49.             availableWords[counter][4] = buffer[4];
  50.             availableWords[counter][5] = buffer[5];
  51.             availableWords[counter][6] = buffer[6];
  52.             availableWords[counter][7] = buffer[7];
  53.             // process buffer
  54.             counter = counter + 1;
  55.         }
  56.        
  57.     }
  58.     if (feof(fptr))
  59.     {
  60.         printf("End of File\n");
  61.         fclose(fptr); //fptr is the file pointer associated with file to be closed.
  62.     }
  63.     else
  64.     {
  65.         // some other error interrupted the read
  66.     }
  67.     srand((unsigned)time(NULL));  // should only be called once
  68.     int r = rand();// % 23206;
  69.     int value = (r % 23206) + 1;
  70.     printf("%i", value);
  71.     return availableWords[value][0];
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement