怎么写啊。。用C++来写
重点是:不过滤空格回车 一个个字符读!!
输出到屏幕上跟原文件格式一致 源文件有空格的 回显也有空格。
关于从一个文档中读入数据(不过滤空格回车)!!C++
答案:4 悬赏:80 手机版
解决时间 2021-01-27 11:41
- 提问者网友:我的未来我做主
- 2021-01-26 15:59
最佳答案
- 五星知识达人网友:鸠书
- 2021-01-26 16:15
C++, 输入文件 test.txt (你可以把源程序内容copy 到 test.txt 作为输入文件 用)。
C++ 程序:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream infile;
infile.open ("test.txt", ifstream::in);
while (infile.good())
cout << (char) infile.get();
infile.close();
return 0;
}
C++ 程序:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream infile;
infile.open ("test.txt", ifstream::in);
while (infile.good())
cout << (char) infile.get();
infile.close();
return 0;
}
全部回答
- 1楼网友:深街酒徒
- 2021-01-26 19:23
语句写对了吗?
程序例子。你试试。一次回车就可以了。
#include
using namespace std;
void main()
{
char s[256];
cout << "enter string with spaces: ";
cin.getline (s,256);
cout << s << endl;
}
- 2楼网友:撞了怀
- 2021-01-26 18:53
std::ifstream in("xxx");
char c;
while( in.get(c) ){
//////
}
- 3楼网友:拜訪者
- 2021-01-26 17:22
什么叫不过滤空格回车?getchar()?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯