how to split a sentence to words
hi guys..
i have few problems in splitting a line to words..
for example, say we enter an address to the system
say
56/90, claus street, birmingham
it should return
unit number : 54
street : claus street
town : birmingham
i'm new to c++ programming and i have no idea about strtok() function. after reading some books and internet searches, i tried it, with little success.
here's my effort (albeit a beginner one)
Code:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main ()
{
char str[200];
char * add;
cout<<"Enter a String"<<flush<<endl;
cin>>add;
while (add != NULL)
{
cout<<"string is:"<<add<<endl;
add = strtok (NULL, " ,.-");
}
system ("pause");
return 0;
}
i'm just not sure about the delimiters.. how can i separate the sentence using the delimiters such as tab, space, or '/' key??
pls help