fork download
  1. #include <stdio.h>
  2.  
  3. int SortDataset(char *filename,int n){
  4. char *type=".sort.txt", *type2=".txt",name[MAXLEN], **mass=(char**)malloc(n*sizeof(char*));
  5. int i;
  6. FILE *file, *sortfile;
  7.  
  8. strcpy(name,filename);
  9. strcat(name,type2);
  10. strcat(filename,type);
  11. file = fopen(name, "r");
  12. for(i=0;i<n;i++)
  13. mass[i]=(char*)malloc(4*sizeof(char));
  14. if (file==0) printf("Error");
  15. i=0;
  16. while(fgets(mass[i],4,file))
  17. i++;
  18. printf("%s",mass[0]);
  19.  
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘SortDataset’:
prog.c:4:48: error: ‘MAXLEN’ undeclared (first use in this function)
     char *type=".sort.txt", *type2=".txt",name[MAXLEN], **mass=(char**)malloc(n*sizeof(char*));
                                                ^~~~~~
prog.c:4:48: note: each undeclared identifier is reported only once for each function it appears in
prog.c:4:72: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
     char *type=".sort.txt", *type2=".txt",name[MAXLEN], **mass=(char**)malloc(n*sizeof(char*));
                                                                        ^~~~~~
prog.c:4:72: warning: incompatible implicit declaration of built-in function ‘malloc’
prog.c:4:72: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
prog.c:8:5: warning: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration]
     strcpy(name,filename);
     ^~~~~~
prog.c:8:5: warning: incompatible implicit declaration of built-in function ‘strcpy’
prog.c:8:5: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
prog.c:9:5: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
     strcat(name,type2);
     ^~~~~~
prog.c:9:5: warning: incompatible implicit declaration of built-in function ‘strcat’
prog.c:9:5: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
prog.c:6:18: warning: unused variable ‘sortfile’ [-Wunused-variable]
     FILE *file, *sortfile;
                  ^~~~~~~~
prog.c:4:43: warning: unused variable ‘name’ [-Wunused-variable]
     char *type=".sort.txt", *type2=".txt",name[MAXLEN], **mass=(char**)malloc(n*sizeof(char*));
                                           ^~~~
prog.c:20:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty