無論哪裏,在新行後面都有一個新行或(「\ n」)和一個空格(「」),我想忽略「\ n」只是在我的輸出中打印空間,我怎麼能這樣做?如何忽略從C++中讀取文本文件中的特定新行
這是一個例子:
newegg
bizrate
想將它更改爲:
newegg bizrate
我很困惑,因爲我想我不能逐行讀取行做到這一點!下面是我的粗略代碼,我不知道如何繼續... 非常感謝。
ifstream file ("input.txt");
ofstream output("output.txt");
string line;
if(file.is_open())
{
while (!file.eof())
{
getline (file, line);
if (line.find("\n"+' ') != string::npos)
{
??
}
非常感謝。它工作正常。 – Omid