fork download
  1. #include <stdio.h>
  2. #define M 100
  3. #define N 8
  4.  
  5. int main(int argc, char* argv[])
  6. {
  7. int count = 0;
  8. int i = 0;
  9. char a[M][N];
  10. char ch;
  11. FILE* ptr = fopen("ride.in","r");
  12. while(fscanf(ptr, "%c", &ch) != EOF && count < M)
  13. {
  14. if(ch == '\n')
  15. {
  16. a[count][N - 1] = '\0';
  17. ++count;
  18. i = 0;
  19. }
  20. else
  21. {
  22. if(i < N - 1)
  23. a[count][i++] = ch;
  24. }
  25. }
  26.  
  27. for(i = 0; i < count; ++i)
  28. {
  29. printf("%s\n", a[i]);
  30. }
  31.  
  32. return 0;
  33. }
Runtime error #stdin #stdout 0s 3268KB
stdin
Standard input is empty
stdout
Standard output is empty