fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. void read_ints(const char* file_name, int *result);
  4.  
  5. int main()
  6. {
  7. int result =0;
  8. read_ints("numbers.txt", &result);
  9. }
  10.  
  11. void read_ints (const char* file_name, int *result)
  12. {
  13. FILE* file = fopen ("numbers.txt", "r");
  14. int i = 0;
  15. int n=0; //row number//
  16. int m;
  17. int tab[m]; //array//
  18. if (file == NULL)
  19. {
  20. printf("unable to open file %s", file_name);
  21. }
  22. while ( fscanf (file, "%d", &i) ==1)
  23. {
  24. n++;
  25. printf ("%d\n ", i);
  26. *result += i;
  27. printf("\n we are at row nr. %d sum of this number and all numbers before is: %d\n", n, *result);
  28. tab[n]==*result;
  29. }
  30. printf("\nnumber from row number one is ... : %d\n", tab[1]); //this does not work properly //
  31. fclose (file);
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘read_ints’:
prog.c:28:14: error: statement with no effect [-Werror=unused-value]
        tab[n]==*result;
        ~~~~~~^~~~~~~~~
prog.c:17:3: error: ‘m’ is used uninitialized in this function [-Werror=uninitialized]
   int tab[m]; //array//
   ^~~
cc1: all warnings being treated as errors
stdout
Standard output is empty