Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Input 10 integers from keyboard to one-dimensional array str[ 10] and write these 10 numbers into file.dat, and then read these data from the file.
Input 10 integers from keyboard to one-dimensional array str[ 10] and write these 10 numbers into file.dat, and then read these data from the file.
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

int main()

{

int str[ 10];

int I;

FILE * fp = NULL

Printf ("Please enter the number 10 \ n");

for(I = 0; I< 10; ++i)

{

scanf("%d ",& ampstr[I]);

}

fp=fopen("file.dat "," w+b ");

If (! fp)

{

Printf ("File open error! \ n ");

Exit (1);

}

for(I = 0; I< 10; ++i)

fprintf(fp," %d%c ",str[i],' \ n ');

int num

fseek(fp,0,SEEK _ SET);

for(I = 0; I< 10; ++i)

{fscanf(fp," %d ",& ampnum);

printf("%d\n ",num);

}

fclose(FP);

Returns 0;

}