我写了下面code.I应该改变标签与法案,但我的代码并nothing.What可问题我的代码是这样的:?文件读写问题
#include <stdio.h>
#include <string.h>
int main()
{
FILE * pFile;
char tag [6];
char code[20]="bill";
pFile = fopen ("example.asm","r+");
if (pFile==NULL)
{
perror("Error");
}
else
{
while(!feof(pFile))
{
fgets(tag,5,pFile);
if((tag=="<bp>") && (!feof(pFile)))
{
fputs(code,pFile);
}
}
}
fclose(pFile);
return 0;
}
它编译完美,因为'tag'和'“”'都是同一类型,'字符*'的三分球,他也因此被比较的地址,而不是字符串。 –
2011-04-10 10:57:20
@Blag - 对。我大约10年没有运行c编译器,我有点生疏。 – Hogan 2011-04-10 10:59:58
非常感谢。它的工作原理。 – Cem 2011-04-10 11:01:50