Something Wrong with the code

#include
#include
using namespace std;

char *mystrtok(char str[], char delim)
{
static char *input = NULL;
if(str!=NULL)
{
input=str;
}
if(input==NULL)
{
return NULL;
}

char *output = new char[strlen(input)+1];

int i;
for(i=0; input[i]!='\0'; i++)
{
    if(input[i]!=delim)
    {
        output[i]=input[i];
    }
    else
    {
        output[i]='\0';
        input=input+i+1;
        return output;
    }
    output[i] = '\0';
    input = NULL;
    return output;

}

}

int main() {

char str[] = "Hello, its me";
char *ptr;

ptr = mystrtok(str,' ');
cout<<ptr<<endl;

ptr = mystrtok(NULL,' ');
cout<<ptr<<endl;

ptr = mystrtok(NULL,' ');
cout<<ptr<<endl;

}

@aposwal first copy your code on ide then share it here and tell me what type of error you get.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.