0
我想要做的是infile一行字符然后对其执行操作将其保存到out文件位置,然后读取下一行并执行相同的操作。如何将多行字符插入到一个数据位置
//seperate function called within int main.
//expression is passed by reference to this function.
ifstream infile;
int i = 0;
infile.open("test.data");
if(infile.fail()){
cout << "ERROR: File failed to open." << endl;
exit(1);
}
while(!infile.eof()){
infile >> expression[i];
while(expression[i +1] != '\o'){
infile >> expression[i + 1];
i++;
}
//perform other operations within a class
//print out results
//read next line from file.
谢谢。我只需要帮助阅读文件中的下一行。可能不完全正确,只是一个粗略的例子。
你试过'getLine'吗?请检查http://www.cplusplus.com/reference/iostream/istream/getline/ – ATaylor
[while(!f.eof())is wrong。](http://stackoverflow.com/questions/5605125/why- is-iostreameof-inside-a-loop-condition-considered-wrong) – interjay
'\ o'是什么?你的意思是'\ 0'吗?什么是表达声明?为什么表达式[i + 1]会变成'\ 0'或'\ o'?谁将在文件中放置'\ 0'? – user93353