我有一個包含文本的文件。我逐行閱讀整個文件並追加到一個字符串對象。但是當我得到最終的字符串打印出來,我沒有得到整個文件的內容。我相信這是由於特殊字符,如「\ n」,「\ r」,「\ t」等存在讀取文件內容的問題
這裏是我的示例代碼:
// Read lines until end of file (null) is reached
do
{
line = "";
inputStream->read_line(line);
cout<<"\n "<<line;//here i get the content of each line
fileContent.append(line);// here i am appending
}while(line.compare("") != 0);
顯示更多的代碼,等,其中聲明'inputStream'和'fileContent'。 – ildjarn 2011-05-10 11:55:21