我正在做一個簡單的任務,我無法輸出預期的輸出。有人可以幫助我找出問題所在的方向嗎?我們不允許使用istringstream。輸入和輸出文本文件
else
{
upData >> houseIdent;
while(upData)
{
do{
upData >> vehType >> plate >> year >> vehPrice;
calculate = calcReg(vehType, plate, year,
vehPrice);
outDataOne << fixed << showpoint << setprecision(2);
outDataOne << ' ' << vehType << ' ' << plate << ' ' << calculate
<< endl;
ch = upData.peek();
}while (upData && (ch != '\n'));
upData >> houseIdent;
}
upData是ifstream .txt,outDataOne是ofstream .txt。輸入與此類似
11111中號DKC294 2007 23001一VID392 2010 10390
22222一DKS382 2011 20390
33333一DKF329 2001 30920中號AJD302 2004年15509
我一直儘管得到的輸出是第一兩條輸出線是正確的,但是第三條線不返回並讀取第二行ID號,但保留11111作爲ID號,同時將vehType設置爲2,將板設置爲0390.我很困惑這個我對C++相當陌生。
在此先感謝
[Works for me](http://ideone.com/HzJoPi) –