Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int index = 0;
  6. char *all_questions[20];
  7. char *all_answers[20];
  8. char *answer;
  9. char *question;
  10. int main()
  11. {
  12.  
  13.  
  14.     FILE *myfile = fopen("D:\\CCrossword\\sample.txt", "r");
  15.  
  16.     if (myfile == NULL)
  17.     {
  18.         printf("Blad przy otwieraniu pliku!\n");
  19.         exit(1);
  20.     }
  21.  
  22.     char line[256];
  23.     while (fgets(line, sizeof(line), myfile)) {
  24.         answer = strtok(line, "|");
  25.         question = strtok(NULL, "");
  26.         all_questions[index] = question;
  27.         all_answers[index] = answer;
  28.         //printf("%s\n", all_questions[index]);
  29.         index++;
  30.         printf("%s\n", all_questions[1]);
  31.     };
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement