我有一个很长的 .txt 文件,我想使用 .txt 流式传输getline
。我想输入整个文本文档,然后通过一个程序运行它。
然后,我想使用不同的值通过相同的过程运行该新字符串,依此类推 2 次。
到目前为止我有
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void flag(string & line, int len);
void cut(string & line, int numb);
int main()
{
string flow;
ifstream input;
ofstream output;
input.open(filename.c_str()); //filename ...
output.open("flow.txt");
while (!input.fail())
getline(input, flow);
flag(flow, 10);
flag(flow, 20);
cut(flow, 20);
cut(flow, 3);
output << flow;
return 10;
}
//procedures are defined below.
我在通过一个过程运行整个文件时遇到了麻烦。我将如何使用getline
.
我试过getline
, infile.fail
, npos
, 等等。