fwrite为何调用失败,应如何修改?
#include <stdio.h>
struct communication
{
int bilseqno[2];
char recordtype;
char recordid;
char naocn;
char cn[20];
}stu;
int main()
{
FILE *fp,*fp1;
if((fp = fopen("d:\\111.txt","r")) == NULL)
{
printf("cannot open the file\n");
exit(0);
}
if (fseek(fp,123L,0))//移动失败,返回非0
{
printf("Seek fail!");
exit(0);
}
if(fread(&stu, sizeof(struct communication), 1, fp) != 1)
{
printf("error\n");
}
if((fp1 = fopen("nidan.txt","w")) == NULL)
{
printf("cannot open the file\n");
exit(0) ;
}
if( fwrite(&stu, sizeof(struct communication), 1, fp1)!=1);
printf("error2\n");
fclose(fp);
fclose(fp1);
}