#include <iostream>
#include <fstream>
#include <string>
using namespace std;
main(){
char citylist[]="3 0 0 6,4 300 3 9,5 250 2 11,8 200 3 14,";
int j=0;
char *onecityptr=NULL;
cout<<"现在拆第"<<j<<"个结构体"<<endl;
onecityptr = strtok(citylist,",");
cout<<"第"<<j<<"个结构体为串:"<<onecityptr<<endl;
while(onecityptr!=NULL)
{
cout<<"工作指针还未到该列表的末尾"<<endl;
cout<<"现在拆第"<<j<<"个结构体"<<endl;
onecityptr = strtok(citylist,",");
cout<<"第"<<j<<"个结构体为串:"<<onecityptr<<endl;
}
system("pause");
return 0;
}
#include <fstream>
#include <string>
using namespace std;
main(){
char citylist[]="3 0 0 6,4 300 3 9,5 250 2 11,8 200 3 14,";
int j=0;
char *onecityptr=NULL;
cout<<"现在拆第"<<j<<"个结构体"<<endl;
onecityptr = strtok(citylist,",");
cout<<"第"<<j<<"个结构体为串:"<<onecityptr<<endl;
while(onecityptr!=NULL)
{
cout<<"工作指针还未到该列表的末尾"<<endl;
cout<<"现在拆第"<<j<<"个结构体"<<endl;
onecityptr = strtok(citylist,",");
cout<<"第"<<j<<"个结构体为串:"<<onecityptr<<endl;
}
system("pause");
return 0;
}
![](http://hiphotos.baidu.com/%B6%FE%D6%D0%D0%A1%C7%BF%C8%CB/pic/item/61bb99edfc0392453ee33ebd8794a4c27c1e25b0.jpg?v=tbs)