#include
#include<string.h>
#include
using namespace std;
char *tok(char s[], char d)
{
static char *ptr=NULL;
if(s!="\0")
{ptr=s;
}
if(ptr==NULL)
{
return NULL;
}
char *output=new char[strlen(s)+1];
int i;
for(i=0;ptr[i]!='\0';i++)
{
if(ptr[i]!=d)
output[i]=ptr[i];
else{
{ output[i]='\0';
ptr=ptr+i+1;
return output;
}
}
output[i]='\0';
ptr=NULL;
return output;
}
int main()
{
char s[]=“hi this is the new way of coding”;
char pt;
pt=tok(s," “);
while(pt!=NULL)
{
cout<<pt<<endl;
pt=tok(NULL,” ");
}
return 0;
}
can anyboldy help it is compiler error
main.cpp: In function ‘char tok(char*, char)’:
main.cpp:44:1: error: a function-definition is not allowed here before ‘{’ token
{
^
main.cpp:55:1: error: expected ‘}’ at end of input
}
^