【发布时间】:2016-08-31 23:16:10
【问题描述】:
我是一个 C 菜鸟,我正在尝试制作一个程序来删除特定的行。为此,我选择复制源文件的内容,跳过打算删除的行。在我的原始代码中,我写道:
while(read_char = fgetc(fp) != '\n') //code to move the cursor position to end of line
{
printf("%c",read_char); //temporary code to see the skipped characters
}
这给了我很多笑脸。
最后我找到了给出预期输出的代码:
read_char=fgetc(fp);
while(read_char != '\n') //code to move the cursor position to end of line
{
printf("%c",read_char); //temporary code to see the skipped characters
read_char=fgetc(fp);
}
但这两个代码之间的实际区别是什么?
【问题讨论】: