#include
#include
#include
using namespace std;
char *mystrtok(char s[],char del)
{
static char *input=NULL;
if(s!=NULL)
{
input=s;
}
if(input==NULL)
return NULL;
char *output=new char[strlen(input)+1];
int i;
for(i=0;input[i]!='\0';++i)
{
if(input[i]!=del)
{
output[i]=input[i];
}
else
{
output[i]='\0';
input=input+i+1;
return output;
}
output[i]='\0';
input=NULL;
return output;
}
}
int main()
{
char s[]=“hello i am atul good morning”;
char *ptr;
ptr=mystrtok(s," ");
cout<<ptr;
while(ptr!=NULL)
{
cout<<ptr<<endl;
ptr=mystrtok(NULL," ");
}
return 0;
}