Code:
string str1(" 1 2 3 4 512543 ");
string str2;
if(str2.empty())
str2=str1;
cout << "str2:" <<str2 <<endl;
p1=strtok((char *)str1.c_str()," ");
while(p1)
{
v1.push_back(atoi(p1));
cout << "val of p1 " << p1 << endl;
p1=strtok(NULL," ");
}
cout << "size of v1 " << v1.size() <<endl;
p2=strtok((char *)str2.c_str()," ");
cout << "str2:" <<str2 <<endl;
while(p2)
{
v2.push_back(atoi(p2));
cout << "val of p2 " << p2 <<endl;
p2=strtok(NULL," ");
}
cout << "size of v2" << v2.size() <<endl;