這只是一個快速問題。但我試圖輸出數據到一個文件,工作正常。 但是我也試圖在適當的位置實施一個新的行,以便在各行上打印數據。C++輸出到文本文件時出現新行字符
這是我的代碼目前的樣子:
的main.cpp
Writer w("Output.txt");
w.writeString("The number of words in the script are: ");
w.writeInt(count);
w.writeEol();
w.writeString("The number of Officers in the script are: ");
w.writeInt(ofCount);
w.writeEol();
w.writeString("The number of Courtiers in the script are: ");
w.writeInt(cCount);
w.close();
Writer.cpp
void Writer::writeEol()
{
out << "\n" << endl;
}
我的代碼已經被實現這種方式爲我的整個系統建立像這樣。
所以我的問題是,我將如何調整我的Writer :: writeEol()來添加一個新行到我的輸出文件?
我的輸出文件目前出來是這樣的:
The number of words in the script are: 32339The number of Officers in the script are: 2The number of Courtiers in the script are: 9
任何幫助是極大的讚賞。 :)
毫無疑問。 – chris
我看不到問題 –
那麼,你有'writeEol'的代碼。什麼不起作用? – chris