fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define ROW 1000
  5. #define COL 10
  6. #define DELIM " \t\r\n"
  7.  
  8. int main(){
  9.  
  10. FILE *fp = fopen("input.txt","r");
  11.  
  12. char buf[BUFSIZ];
  13. char *p;
  14.  
  15. float arr[ROW][COL];
  16.  
  17. int row = 0;
  18. int col;
  19.  
  20. if(fp == NULL){
  21. printf("fopen failed\n");
  22. goto ERROR;
  23. }
  24.  
  25. while(fgets(buf,BUFSIZ,fp) != NULL){
  26. col = 0;
  27. for(p = strtok(buf,DELIM); p != NULL; p = strtok(NULL,DELIM)){
  28. sscanf(p,"%f",&arr[row][col++]);
  29. }
  30. ++row;
  31. }
  32.  
  33. fclose(fp);
  34.  
  35. return 0;
  36.  
  37. ERROR:
  38. return -1;
  39.  
  40. }
Runtime error #stdin #stdout 0s 2424KB
stdin
Standard input is empty
stdout
fopen failed