#include <stdio.h>
static int is_substring( const char *dest, const char *src, int len)
{
int i;
for(i = 0;i < len; i++)
{
if(src[i] != dest[i])
{
return(0);
}
}
return(1);
}
char *my_strtok(char *str, const char *delim)
{
int i = 0;
int len = strlen(delim);
char *ret_p;
char *temp;
static char *save_p;
temp = (str == NULL) ? save_p : str;
ret_p = temp;
if(1 == len)
{
/*****************************************/
while(*temp != '\0')
{
if(*delim == *temp)
{
*temp = '\0';
save_p = ++temp;
return(ret_p);
}
temp++;
}
// return(NULL);
}
else
{
/******************************************/
while(*temp != '\0')
{
if(is_substring(temp,delim,len) == 1)
{
*temp = '\0';
save_p = temp + len;
return(ret_p);
}
temp++;
}
// return(NULL);
}
return(NULL);
}
static int is_substring( const char *dest, const char *src, int len)
{
int i;
for(i = 0;i < len; i++)
{
if(src[i] != dest[i])
{
return(0);
}
}
return(1);
}
char *my_strtok(char *str, const char *delim)
{
int i = 0;
int len = strlen(delim);
char *ret_p;
char *temp;
static char *save_p;
temp = (str == NULL) ? save_p : str;
ret_p = temp;
if(1 == len)
{
/*****************************************/
while(*temp != '\0')
{
if(*delim == *temp)
{
*temp = '\0';
save_p = ++temp;
return(ret_p);
}
temp++;
}
// return(NULL);
}
else
{
/******************************************/
while(*temp != '\0')
{
if(is_substring(temp,delim,len) == 1)
{
*temp = '\0';
save_p = temp + len;
return(ret_p);
}
temp++;
}
// return(NULL);
}
return(NULL);
}