Advertisement
mateuspl

reading.c

Jan 10th, 2013
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Part of a program that read a file. */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7.     FILE *mainfile;
  8.     mainfile = fopen("texto.txt", "r+");
  9.     if (mainfile == NULL) { printf("ERROR"); }
  10.     else { printf("OK"); }
  11.  
  12.     unsigned char string[100][10001];    // [line break][letters]
  13.     int qnt;    // amount of line break
  14.     int f, f2;    // any use (for)
  15.  
  16.  
  17.     for (qnt = 0; qnt < 100; qnt++) {
  18.         printf("\n=== Point ===");    // the error happens after "=== point ==="
  19.         fgets(mainfile, 9999, string[qnt]);
  20. /*
  21. The compiler compiles, but also presents these two errors:
  22.    [Warning] passing arg 1 of `fgets' from incompatible pointer type
  23.    [Warning] passing arg 3 of `fgets' from incompatible pointer type
  24. */
  25.         for (f = 0; f < 9999; f++) {
  26.             printf("\n> %d", f);
  27.                 if (string[qnt][f] == 255) { goto goto_EOF; }
  28.                 if (string[qnt][f] == '\0') { break; }
  29.         }
  30.     }
  31. goto_EOF:
  32. (...) }
  33.  
  34. RUN:
  35.  
  36. >>> OK.
  37. >>> === Point ===
  38.  
  39. The program crashes <<<
  40.  
  41. :END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement