fork download
  1. /*компоненты бинарного файла-записи,
  2. состоящие из четырех чисел-координат центра кольца и его внешнего и внутреннего радиусов.
  3. Определить, какое кольцо имеет наибольшую площадь, какое-наименьшую.*/
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #define N 9
  7. int InputStruct(int,);
  8. void OutputStruct(struct);
  9. int SeachMaxMin(,int);
  10. struct {
  11. float x, y, r, R;
  12. int NumerRing;
  13. } ringArr[N],*pRing;
  14.  
  15. int main(void)
  16. {
  17. int i,number;
  18. char filename[15];
  19. FILE *pFile;
  20. puts("input filename");
  21. gets(filename);
  22. if((pFile=fopen(filename,"a+b"))==NULL)
  23. {
  24. printf("can't open '%s'",filename);
  25. return 1;
  26. }
  27. do
  28. {
  29. printf("input number rings(no bigger %d):",N);
  30. scanf("%d",&number);
  31. }
  32. while(number<0 && number>N);
  33. printf("input parametes your ring");
  34. for(i=0;i<number;i++)
  35. {
  36. InputStruct(i,);
  37. OutputStruct();
  38. }
  39. fwrite(*pRing,sizeof(*pRing),pFile);
  40. fread(*pRing,sizeof(*pRing),pFile);
  41. SeachMaxMin();
  42. fclose(pFile);
  43. return 0;
  44. }
  45. int InputStruct(int i,)
  46. {
  47. pRing->NumberRing=i+1;
  48. scanf("%*c");
  49. puts("enter x:");
  50. scanf("%f\n",&(pRing->x));
  51. puts("enter y:");
  52. scanf("%f", &(pRing->y));
  53. puts("enter internal radius:");
  54. scanf("%f\n",&(pRing->r));
  55. puts("enter external radius:");
  56. scanf("%f\n",&(pRing->R));
  57. return 0;
  58. }
  59. void OutputStruct(struct ring *pStruct)
  60. {
  61. printf("\nNumber ring:%d\tx=%f\ty=%d\tr=%d\tR=%d\t\n",pRing->NumberRing,pRing->x,pRing->y,pRing->r,pRing->R);
  62. return;
  63. }
  64. int SearchMaxMin(*pStruct,int n)
  65. {
  66. for(i=0;i<n;i++)
  67. {
  68.  
  69. }
  70. return 1;
  71. }
  72.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:7:21: error: expected declaration specifiers or '...' before ')' token
 int InputStruct(int,);
                     ^
prog.c:8:25: error: expected '{' before ')' token
 void OutputStruct(struct);
                         ^
prog.c: In function 'main':
prog.c:21:5: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration]
     gets(filename);
     ^
prog.c:36:9: warning: implicit declaration of function 'InputStruct' [-Wimplicit-function-declaration]
         InputStruct(i,);
         ^
prog.c:36:23: error: expected expression before ')' token
         InputStruct(i,);
                       ^
prog.c:37:9: error: too few arguments to function 'OutputStruct'
         OutputStruct();
         ^
prog.c:8:6: note: declared here
 void OutputStruct(struct);
      ^
prog.c:39:12: error: incompatible type for argument 1 of 'fwrite'
     fwrite(*pRing,sizeof(*pRing),pFile);
            ^
In file included from prog.c:4:0:
/usr/include/stdio.h:715:15: note: expected 'const void * restrict' but argument is of type 'struct <anonymous>'
 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
               ^
prog.c:39:34: warning: passing argument 3 of 'fwrite' makes integer from pointer without a cast [-Wint-conversion]
     fwrite(*pRing,sizeof(*pRing),pFile);
                                  ^
In file included from prog.c:4:0:
/usr/include/stdio.h:715:15: note: expected 'size_t {aka unsigned int}' but argument is of type 'FILE * {aka struct _IO_FILE *}'
 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
               ^
prog.c:39:5: error: too few arguments to function 'fwrite'
     fwrite(*pRing,sizeof(*pRing),pFile);
     ^
prog.c:40:11: error: incompatible type for argument 1 of 'fread'
     fread(*pRing,sizeof(*pRing),pFile);
           ^
In file included from prog.c:4:0:
/usr/include/stdio.h:709:15: note: expected 'void * restrict' but argument is of type 'struct <anonymous>'
 extern size_t fread (void *__restrict __ptr, size_t __size,
               ^
prog.c:40:33: warning: passing argument 3 of 'fread' makes integer from pointer without a cast [-Wint-conversion]
     fread(*pRing,sizeof(*pRing),pFile);
                                 ^
In file included from prog.c:4:0:
/usr/include/stdio.h:709:15: note: expected 'size_t {aka unsigned int}' but argument is of type 'FILE * {aka struct _IO_FILE *}'
 extern size_t fread (void *__restrict __ptr, size_t __size,
               ^
prog.c:40:5: error: too few arguments to function 'fread'
     fread(*pRing,sizeof(*pRing),pFile);
     ^
In file included from prog.c:4:0:
/usr/include/stdio.h:709:15: note: declared here
 extern size_t fread (void *__restrict __ptr, size_t __size,
               ^
prog.c:41:5: warning: implicit declaration of function 'SeachMaxMin' [-Wimplicit-function-declaration]
     SeachMaxMin();
     ^
prog.c: At top level:
prog.c:45:23: error: expected declaration specifiers or '...' before ')' token
 int InputStruct(int i,)
                       ^
prog.c:59:26: warning: 'struct ring' declared inside parameter list
 void OutputStruct(struct ring *pStruct)
                          ^
prog.c:59:26: warning: its scope is only this definition or declaration, which is probably not what you want
prog.c:59:6: error: conflicting types for 'OutputStruct'
 void OutputStruct(struct ring *pStruct)
      ^
prog.c:8:6: note: previous declaration of 'OutputStruct' was here
 void OutputStruct(struct);
      ^
prog.c: In function 'OutputStruct':
prog.c:61:64: error: 'struct <anonymous>' has no member named 'NumberRing'
     printf("\nNumber ring:%d\tx=%f\ty=%d\tr=%d\tR=%d\t\n",pRing->NumberRing,pRing->x,pRing->y,pRing->r,pRing->R);
                                                                ^
prog.c: At top level:
prog.c:64:18: error: expected declaration specifiers or '...' before '*' token
 int SearchMaxMin(*pStruct,int n)
                  ^
stdout
Standard output is empty