有关结构的小问题。。请教
KyoUs 2002-09-22 09:23:14
#include <stdio.h>
#define N 3
struct staff
{
char num[7];
char name[10];
double score;
} student[N];
void savef ( void )
{
FILE* fp;
int i;
if ((fp=fopen("work.dat","wb"))==NULL)
{
printf("Can not open the file.\n");
return;
}
for (i=0;i<N;i++)
if (fwrite(&student[i],sizeof(struct staff),1,fp)!=1)
printf("File write error.\n");
fclose(fp);
}
void main(void)
{
printf("\nInput %d student\'s No. name score:\n",N);
for (int i=0;i<N;i++)
{
gets(student[i].num);
gets(student[i].name);
scanf("%*c%f",&student[i].score);
}
savef();
}
-------------------------------------------
主要是scanf("%*c%f",&student[i],score);这句有问题。。。和我想的不一样
怎么改??