fork download
  1. struct hoso{
  2. int stt;
  3. char ten[100];
  4. float nhap;
  5. float xuat;
  6. };
  7.  
  8. int count(){
  9. int c=0;
  10. hoso goods[100];
  11. FILE *p = fopen( "B18DCCN526.txt", "r");
  12. char s[60];
  13. while( fscanf( p, "%d", &goods[c] . stt) != EOF){
  14. fgets( goods[c] . ten, 40, p);
  15. fscanf( p, "%.2f%.2f" ,&goods[c] . nhap, &goods[c] . xuat);
  16. c++;
  17. }
  18. fclose(p);
  19. return c;
  20. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘count’:
prog.c:10:2: error: unknown type name ‘hoso’
  hoso goods[100];
  ^~~~
prog.c:10:2: note: use ‘struct’ keyword to refer to the type
prog.c:11:2: error: unknown type name ‘FILE’
  FILE *p = fopen( "B18DCCN526.txt", "r");
  ^~~~
prog.c:11:12: warning: implicit declaration of function ‘fopen’ [-Wimplicit-function-declaration]
  FILE *p = fopen( "B18DCCN526.txt", "r");
            ^~~~~
prog.c:11:12: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
prog.c:13:9: warning: implicit declaration of function ‘fscanf’ [-Wimplicit-function-declaration]
  while( fscanf( p, "%d", &goods[c] . stt) != EOF){
         ^~~~~~
prog.c:13:9: warning: incompatible implicit declaration of built-in function ‘fscanf’
prog.c:13:9: note: include ‘<stdio.h>’ or provide a declaration of ‘fscanf’
prog.c:13:36: error: request for member ‘stt’ in something not a structure or union
  while( fscanf( p, "%d", &goods[c] . stt) != EOF){
                                    ^
prog.c:13:46: error: ‘EOF’ undeclared (first use in this function)
  while( fscanf( p, "%d", &goods[c] . stt) != EOF){
                                              ^~~
prog.c:13:46: note: each undeclared identifier is reported only once for each function it appears in
prog.c:14:3: warning: implicit declaration of function ‘fgets’ [-Wimplicit-function-declaration]
   fgets( goods[c] . ten, 40, p);
   ^~~~~
prog.c:14:19: error: request for member ‘ten’ in something not a structure or union
   fgets( goods[c] . ten, 40, p);
                   ^
prog.c:15:36: error: request for member ‘nhap’ in something not a structure or union
   fscanf( p, "%.2f%.2f" ,&goods[c] . nhap, &goods[c] . xuat);
                                    ^
prog.c:15:54: error: request for member ‘xuat’ in something not a structure or union
   fscanf( p, "%.2f%.2f" ,&goods[c] . nhap, &goods[c] . xuat);
                                                      ^
prog.c:18:2: warning: implicit declaration of function ‘fclose’ [-Wimplicit-function-declaration]
  fclose(p);
  ^~~~~~
prog.c:12:7: warning: unused variable ‘s’ [-Wunused-variable]
  char s[60];
       ^
prog.c:10:7: warning: variable ‘goods’ set but not used [-Wunused-but-set-variable]
  hoso goods[100];
       ^~~~~
stdout
Standard output is empty