我想在一個文件中打印出3行,但是最終發生的是它在所有3個點中打印1行,打印所有3個點中的第二行,然後,好吧,你猜對了,與第三次相同。我希望它在按下一次按鈕時打印出全部3行。有任何想法嗎?如何從同一個文件同時打印出3行?
ifstream read_file;
string fname, name;
cout << "Type the complete address of the file you would like to open.\n";
cin >> fname;
system("cls");
read_file.open(fname.c_str());
while(getline(read_file, fname))
{
if (fname == "")continue;
cout << "You had "<< fname << " health left\n";
cout << "You delt " << fname << " damage\n";
cout << "There were " << fname << " enemies left\n";
system("pause");
}
read_file.close();
system("pause");
不知道你的意思,你能給什麼它做一個例子,你想它待辦事項什麼? – dchhetri 2013-05-06 14:45:43
你能告訴我們你的代碼嗎? – 2013-05-06 14:45:45
我們需要查看您的代碼,爲什麼不發佈正在進行打印的代碼片段。 – 2013-05-06 14:45:46