【发布时间】:2013-06-18 19:03:26
【问题描述】:
我目前有一个在控制台上打印文本文件的程序,但每一行下面都有一个额外的新行。 如果文本是
你好 世界
它会输出 你好
世界
代码是这样的
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
FILE* fp;
char input[80], ch = 'a';
char key[] = "exit\n";
int q;
fp = fopen("c:\\users\\kostas\\desktop\\original.txt", "r+");
while (!feof(fp)) {
fgets(input, 80, fp);
puts(input);
}
fclose(fp);
return 0;
}
【问题讨论】: