#include<stdio.h>
#include<malloc.h>
struct bmi {
char name[ 100 ] ; /* 氏名 */
double height; /* 身長 */
double weight; /* 体重 */
double bmi;
} ;
int count_number( FILE * fp)
struct bmi * alloc_bmi_array( FILE * number)
int main ( void )
{
char FILENAME[ 100 ] ;
FILE * fp;
int number;
struct bmi * bmis;
if ( ( fp
= fopen ( FILENAME
, 'r' ) == NULL
) { fprintf ( stderr
, "%s cannot be opened!\n " , FILENAME
) ; retrun 1 ;
}
number = count_number( fp) ; //データの数を数える
bmis= allocate_bmi_array( number) ; //
// (struct bmi *) malloc(sizeof(struct bmi ) *number)
read_data( fp, bmis) ;
b_sort( bmis) ;
display( bmis) ;
return 0 ;
}
int count_number( FILE * fp) {
int n;
char namme[ 100 ] ;
float height, weight;
n= 0 ;
while ( fscanf ( fp
, "%s %f %f" , name
,& height
,& weight
) != EOF
) { n++;
}
return n;
}
struct bmi
malloc ( sizeof ( struct bmi
) * number
)
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8bWFsbG9jLmg+CgpzdHJ1Y3QgYm1pIHsKICBjaGFyIG5hbWVbMTAwXTsgIC8qIOawj+WQjSAqLwogIGRvdWJsZSBoZWlnaHQ7ICAvKiDouqvplbcgKi8KICBkb3VibGUgd2VpZ2h0OyAgLyog5L2T6YeNICovCiAgZG91YmxlIGJtaTsKfTsKCmludCBjb3VudF9udW1iZXIoRklMRSAqZnApCnN0cnVjdCBibWkgKmFsbG9jX2JtaV9hcnJheShGSUxFICpudW1iZXIpCmludCBtYWluICh2b2lkKQp7CiAgICBjaGFyIEZJTEVOQU1FWzEwMF07CiAgICBGSUxFICpmcDsKICAgIGludCBudW1iZXI7CiAgICBzdHJ1Y3QgYm1pICpibWlzOwoKICAgIHNjYW5mKCIlcyIsRklMRU5FTUUpOwogICAgaWYoKGZwID0gZm9wZW4oRklMRU5BTUUsJ3InKT09TlVMTCl7CiAgICBmcHJpbnRmKHN0ZGVyciwiJXMgY2Fubm90IGJlIG9wZW5lZCFcbiIsRklMRU5BTUUpOwogICAgcmV0cnVuIDE7CiAgICB9CgogICAgbnVtYmVyID0gY291bnRfbnVtYmVyKGZwKTsvL+ODh+ODvOOCv+OBruaVsOOCkuaVsOOBiOOCiwogICAgYm1pcz0gYWxsb2NhdGVfYm1pX2FycmF5KG51bWJlcik7Ly8KICAgICAgLy8gKHN0cnVjdCBibWkgKikgbWFsbG9jKHNpemVvZihzdHJ1Y3QgYm1pICkgKm51bWJlcikKICAgIHJlYWRfZGF0YShmcCxibWlzKTsKICAgIGJfc29ydChibWlzKTsKICAgIGRpc3BsYXkoYm1pcyk7CgogICAgZmNsb3NlKGZwKTsKICAgIHJldHVybiAwOwp9CgppbnQgY291bnRfbnVtYmVyKEZJTEUgKmZwKXsKICAgIGludCBuOwogICAgY2hhciBuYW1tZVsxMDBdOwogICAgZmxvYXQgaGVpZ2h0LHdlaWdodDsKICAgIG49MDsKICAgIHdoaWxlKGZzY2FuZihmcCwiJXMgJWYgJWYiLG5hbWUsJmhlaWdodCwmd2VpZ2h0KSE9RU9GKXsKICAgICAgICBuKys7CiAgICB9CnJld2luZChmcCk7CiAgICByZXR1cm4gbjsKfQoKc3RydWN0IGJtaQogICAgbWFsbG9jKHNpemVvZihzdHJ1Y3QgYm1pICkgKiBudW1iZXIp
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