我实际上遇到的问题不是只有2到3个程序使用文件及其命令,如fopen,fscanf,while(strcmp(输入," E")!= 0).Atleast ,我认为这是问题所在。所有这些程序都显示出与调试断言失败相同的错误!表达式(流!= null)。我尝试了一切,但似乎没有任何工作请帮忙。我不明白该怎么做。请尽快回复。这是其中一个计划:
# include <stdio.h>
# include <conio.h>
# include <string.h>
# include <stdlib.h>
void main()
{ char add[6],length[10],input[10],binary[12],bitmask[12],relocbit;
int start,inp,len,i,address,opcode,addr,actualadd;
FILE *fp1=fopen("relinput.dat","r");
FILE *fp2=fopen("reloutput.dat","w");
system("cls");
printf("Enter the actual starting address : ");
scanf("%d",&start);
fscanf(fp1,"%s",input);
while(strcmp(input,"E")!=0)
{ if(strcmp(input,"H")==0)
{ fscanf(fp1,"%s",add);
fscanf(fp1,"%s",length);
fscanf(fp1,"%s",input);
}
if(strcmp(input,"T")==0)
{ fscanf(fp1,"%d",&address);
fscanf(fp1,"%s",bitmask);
address+=start;
len=strlen(bitmask);
for(i=0;i<len;i++)
{ fscanf(fp1,"%d",&opcode);
fscanf(fp1,"%d",&addr);
relocbit=bitmask[i];
if(relocbit=='0')
actualadd=addr;
else
actualadd=addr+start;
fprintf(fp2,"%d\t%d%d\n",address,opcode,actualadd);
address+=3;
}
fscanf(fp1,"%s",input);
}
}
fclose(fp1);
fclose(fp2);
printf("FINISHED");
getch();
}
答案 0 :(得分:0)
您需要对fopen程序进行错误检查。此错误很可能是由于fscanf或fopen返回了您未捕获的意外值。
更多有用的提示: