这样对吗?

starcat starcat 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
做一个习题
/*
Display a file a line at a time, waiting for the user to press
the "Enter" key after each line.
*/

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
using namespace std;

int main() {
vector<string> lines;
ifstream in("filename.cpp");
string line;
while(getline(in, line))
lines.push_back(line);
char ch;
for(int i = 0; i < lines.size(); i++) {
cout << lines[i];
cin.get();
cout << endl;
}
}

不知符不符合题意
不想用C的方法getchar()来判断回车,求指点
...全文
评论 3
收藏 已收藏
分享
返回顶部
starcat
新手乐园 33,315 成员 41,769 内容