fork download
  1. #include<stdio.h>
  2. #include<malloc.h>
  3.  
  4. struct bmi {
  5. char name[100]; /* 氏名 */
  6. double height; /* 身長 */
  7. double weight; /* 体重 */
  8. double bmi;
  9. };
  10.  
  11. int count_number(FILE *fp)
  12. struct bmi *alloc_bmi_array(FILE *number)
  13. int main (void)
  14. {
  15. char FILENAME[100];
  16. FILE *fp;
  17. int number;
  18. struct bmi *bmis;
  19.  
  20. scanf("%s",FILENEME);
  21. if((fp = fopen(FILENAME,'r')==NULL){
  22. fprintf(stderr,"%s cannot be opened!\n",FILENAME);
  23. retrun 1;
  24. }
  25.  
  26. number = count_number(fp);//データの数を数える
  27. bmis= allocate_bmi_array(number);//
  28. // (struct bmi *) malloc(sizeof(struct bmi ) *number)
  29. read_data(fp,bmis);
  30. b_sort(bmis);
  31. display(bmis);
  32.  
  33. fclose(fp);
  34. return 0;
  35. }
  36.  
  37. int count_number(FILE *fp){
  38. int n;
  39. char namme[100];
  40. float height,weight;
  41. n=0;
  42. while(fscanf(fp,"%s %f %f",name,&height,&weight)!=EOF){
  43. n++;
  44. }
  45. rewind(fp);
  46. return n;
  47. }
  48.  
  49. struct bmi
  50. malloc(sizeof(struct bmi ) * number)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘count_number’:
prog.c:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
prog.c:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
prog.c:50: error: expected declaration specifiers or ‘...’ before ‘sizeof’
prog.c:50: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ at end of input
stdout
Standard output is empty