#include <iostream.h>
#include <conio.h>
#include <string.h>
void main ( )
{
char source [] = "Hello, Have a Nice Day" ;
char *p;
cout<< "\n Source String is : "<<source ;
/* strtok( ) places a NULL terminator
in front of the token, if found */
p = strtok ( source, "," ) ;
if ( p )
cout<< "\n First Token : "<<p;
/* A second call to strtok( ) using a NULL
as the first parameter returns a pointer
to the character following the token */
p = strtok ( NULL, " " ) ;
if ( p )
cout<< "\n Second Token : "<<p;
/* Similarly other tokens can be obtained */
p = strtok ( NULL, " " ) ;
if ( p )
cout<< "\n Third Token : "<<p;
getch ( ) ;
}
0 comments:
Post a Comment