Eng-Mohamed-Essam

Untitled

Sep 10th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.     FILE *fp; // File pointer
  7.     fp = fopen("C:\\Users\\carniavl\\Desktop\\MIA-Task5\\Task 5\\Part A test cases\\invalid1.txt", "r"); // Function for opening the file and setting it to read only
  8.     if (fp == NULL){ // In case we can't open the file
  9.         printf("Could not open file ");
  10.         return 1;
  11.     }
  12.     char Game[18][9];
  13.     int i, j;
  14.     for (i = 0; i < 18; i++){
  15.         for (j = 0; j < 9; j++){
  16.             fscanf(fp, "%c" ,&Game[i][j]);
  17.         }
  18.     }
  19.     for (i = 0; i < 18; i++){
  20.         for (j = 0; j < 9; j++){
  21.             printf("%c",Game[i][j]);
  22.         }
  23.     }
  24.     if (Game[18][9] < '9' && Game[18][9] > '0'){
  25.         printf("\nThe Game Has Only Integers");
  26.     }
  27.     else {
  28.         printf("\nThe Game contains other symbols than Integers");
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment