[問題] 關於跑while 莫名奇妙跳出去的問題
#include<iostream>
#include<cstdlib>
#include<vector>
#include<fstream>
#include<string>
using namespace std;
int main()
{
vector <string> temp_store;
string temp_area;
char *test;
ifstream iFile;
iFile.open ( "new.txt" );
getline (iFile ,temp_area );
test = strtok ( (char*)temp_area.c_str(), "< >" );
temp_store.push_back(test);
while ( test != NULL )
{
test = strtok (NULL, "< >");
temp_store.push_back(test);
}
cout <<temp_area <<endl;
cout << temp_store[0]<<endl;
cout << temp_store[1]<<endl;
cout << temp_store[3]<<endl;
cout << temp_store[4]<<endl;
cout << temp_store[5]<<endl;
system("pause");
return 0;
}
new.txt的內容
是類似<<12>> <<13>> <<14>> 這種東西一行
但是在while 把最後一個token(14) push_back到vector之後
while 就直接跳出去了...連下面的cout 都沒執行
想請問高手們 這是什麼狀況呢~"~
--
龍五只要手上有槍 誰也殺不了他!!
http://www.wretch.cc/album/adwind
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.128.41.103
※ 編輯: adwind 來自: 140.128.41.103 (05/23 13:04)
推
05/23 13:14, , 1F
05/23 13:14, 1F
→
05/23 13:15, , 2F
05/23 13:15, 2F
→
05/23 13:15, , 3F
05/23 13:15, 3F
→
05/26 21:39, , 4F
05/26 21:39, 4F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章