fork download
  1. void old(FILE *tf)
  2. {struct tov tmp_buffer[10];
  3. int r=9, j;
  4. clrscr();
  5. tf=fopen("spisok.dat","rb+");
  6. for (int k=0; k<=r; k++)
  7. {fread(&tmp_buffer[k],sizeof(t1),1,tf);
  8. }
  9. for (k=0,j=1; k<=r;k++)
  10. {printf("\n%3d %12s %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
  11. j++;
  12. }
  13. struct tov *tmp[10];
  14. for(int h=0;h<12;h++)
  15. {tmp[h]=&tmp_buffer[h];
  16. }
  17. for(int t = 0; t < r; t++)
  18. for(int l = t + 1; l < r;l++)
  19. {
  20. if(tmp_buffer[t].y < tmp_buffer[l].y)
  21. swap(tmp[t], tmp[l]);
  22. else
  23. if(tmp_buffer[t].y == tmp_buffer[l].y)
  24. {
  25. if(tmp_buffer[t].m < tmp_buffer[l].m)
  26. swap(tmp[t], tmp[l]);
  27. else
  28. if(tmp_buffer[t].m == tmp_buffer[l].m)
  29. if(tmp_buffer[t].d < tmp_buffer[l].d)
  30. swap(tmp[t], tmp[l]);
  31. }
  32. }
  33. puts ("\n The oldest item is:");
  34. printf ("\n%12s %2d.%2d.%4d ", tmp_buffer[t].name,tmp_buffer[t].d,tmp_buffer[t].m,tmp_buffer[t].y);
  35. fclose(tf);
  36. }
  37.  
  38. void swap(tov *a,tov *b)
  39. {
  40. tov c=*a;
  41. *a=*b;
  42. *b=c;
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:10: error: unknown type name 'FILE'
void old(FILE *tf)
         ^
prog.c:2:23: error: array has incomplete element type 'struct tov'
{struct tov tmp_buffer[10];
                      ^
prog.c:2:9: note: forward declaration of 'struct tov'
{struct tov tmp_buffer[10];
        ^
prog.c:4:2: warning: implicit declaration of function 'clrscr' is invalid in C99 [-Wimplicit-function-declaration]
 clrscr();
 ^
prog.c:5:5: warning: implicit declaration of function 'fopen' is invalid in C99 [-Wimplicit-function-declaration]
 tf=fopen("spisok.dat","rb+");
    ^
prog.c:7:3: warning: implicit declaration of function 'fread' is invalid in C99 [-Wimplicit-function-declaration]
 {fread(&tmp_buffer[k],sizeof(t1),1,tf);
  ^
prog.c:7:31: error: use of undeclared identifier 't1'
 {fread(&tmp_buffer[k],sizeof(t1),1,tf);
                              ^
prog.c:9:7: error: use of undeclared identifier 'k'
 for (k=0,j=1; k<=r;k++)
      ^
prog.c:9:16: error: use of undeclared identifier 'k'
 for (k=0,j=1; k<=r;k++)
               ^
prog.c:9:21: error: use of undeclared identifier 'k'
 for (k=0,j=1; k<=r;k++)
                    ^
prog.c:10:3: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)'
 {printf("\n%3d %12s  %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
  ^
prog.c:10:3: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
prog.c:10:50: error: use of undeclared identifier 'k'
 {printf("\n%3d %12s  %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
                                                 ^
prog.c:10:70: error: use of undeclared identifier 'k'
 {printf("\n%3d %12s  %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
                                                                     ^
prog.c:10:87: error: use of undeclared identifier 'k'
 {printf("\n%3d %12s  %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
                                                                                      ^
prog.c:10:104: error: use of undeclared identifier 'k'
 {printf("\n%3d %12s  %2d.%2d.%4d",j, tmp_buffer[k].name, tmp_buffer[k].d, tmp_buffer[k].m, tmp_buffer[k].y);
                                                                                                       ^
prog.c:21:13: warning: implicit declaration of function 'swap' is invalid in C99 [-Wimplicit-function-declaration]
            swap(tmp[t], tmp[l]);
            ^
prog.c:33:1: warning: implicit declaration of function 'puts' is invalid in C99 [-Wimplicit-function-declaration]
puts ("\n The oldest item is:");
^
prog.c:34:43: error: use of undeclared identifier 't'
printf ("\n%12s %2d.%2d.%4d ", tmp_buffer[t].name,tmp_buffer[t].d,tmp_buffer[t].m,tmp_buffer[t].y);
                                          ^
prog.c:34:62: error: use of undeclared identifier 't'
printf ("\n%12s %2d.%2d.%4d ", tmp_buffer[t].name,tmp_buffer[t].d,tmp_buffer[t].m,tmp_buffer[t].y);
                                                             ^
prog.c:34:78: error: use of undeclared identifier 't'
printf ("\n%12s %2d.%2d.%4d ", tmp_buffer[t].name,tmp_buffer[t].d,tmp_buffer[t].m,tmp_buffer[t].y);
                                                                             ^
prog.c:34:94: error: use of undeclared identifier 't'
printf ("\n%12s %2d.%2d.%4d ", tmp_buffer[t].name,tmp_buffer[t].d,tmp_buffer[t].m,tmp_buffer[t].y);
                                                                                             ^
prog.c:35:1: warning: implicit declaration of function 'getch' is invalid in C99 [-Wimplicit-function-declaration]
getch();
^
prog.c:36:1: warning: implicit declaration of function 'fclose' is invalid in C99 [-Wimplicit-function-declaration]
fclose(tf);
^
prog.c:39:11: error: unknown type name 'tov'
void swap(tov *a,tov *b)
          ^
prog.c:39:18: error: unknown type name 'tov'
void swap(tov *a,tov *b)
                 ^
prog.c:41:1: error: use of undeclared identifier 'tov'
tov c=*a;
^
prog.c:43:4: error: use of undeclared identifier 'c'
*b=c;
   ^
8 warnings and 18 errors generated.
stdout
Standard output is empty