this code is giving runtime error
#include
#include
using namespace std;
char* mytok(char input[],char e)
{
int i;
static char* a= NULL;
char* output=new char[strlen(input)+1];
if(input!="\0")
{
a=input;
}
if(a==NULL)
return NULL;
for( i=0;a[i]!=’\0’;i++)
{
if(a[i]!=e){
output[i]=a[i];
}
else
{
output[i]=’\0’;
a=a+i+1;
return output;
}
}
output[i]=’\0’;
a=NULL;
return output;
}
int main()
{
char a[]=“My name is XYZ and …”;
char* ptr;
ptr=mytok(a,’ ‘);
while(ptr!=NULL)
{
cout<<ptr<<endl;
ptr=mytok(NULL,’ ');
// cout<<ptr;
}
return 0;
}