菜b有个课程设计。我前面一小部分就出问题了。写入文件怎么出错儿了?
#include<stdio.h>struct student
{
char name[10];
char sex;
int phone;
char adress[20];
int QQ;
};
int main()
{
int i;
struct student stu[10]={{"Lily",'W',111123,"apple road",56443256},
{"Bob",'M',656411,"banaba road",83254467},
{"Tom",'M',897523,"tower road",564432123},
{"Kity",'W',495821,"rain road",56458369},
{"Tony",'M',367498,"gold road",564454781},
{"Sed",'M',232599,"air road",294658715}};
FILE*fp;
fp=fopen("D:\\"stu.dat","wb");
for(i=0;i<10;i++)
fread(&student[10],sizeof(struct student),1,fp);
fclose(fp);
for (i=0;i<10;i++)
printf("%s\t%c\t%5d\t%s\t%5d\n",stu[i].name,stu[i].sex,stu[i].phone,stu[i].adress,stu[i].QQ);
return 0;
}
í¨Ñ¶Â¼.cpp
C:\Users\Administrator\Desktop\Debug\D½¨Îļt¼D (10)\í¨Ñ¶Â¼.cpp(22) : error C2146: syntax error : missing ')' before identifier 'stu'
C:\Users\Administrator\Desktop\Debug\D½¨Îļt¼D (10)\í¨Ñ¶Â¼.cpp(22) : error C2660: 'fopen' : function does not take 1 parameters
C:\Users\Administrator\Desktop\Debug\D½¨Îļt¼D (10)\í¨Ñ¶Â¼.cpp(22) : error C2001: newline in constant
C:\Users\Administrator\Desktop\Debug\D½¨Îļt¼D (10)\í¨Ñ¶Â¼.cpp(23) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Users\Administrator\Desktop\Debug\D½¨Îļt¼D (10)\í¨Ñ¶Â¼.cpp(23) : error C2143: syntax error : missing ';' before ')'
Ö′DD cl.exe ê±3ö′í.
í¨Ñ¶Â¼.exe - 1 error(s), 0 warning(s)