Hello,
I have developed my own version of strtok. Just to practice the use of pointers.
Can anyone see any limitations with this or anyway I can improve.
void stvstrtok(const char *source, char *dest, const char token)
{
/* Search for the token. */
int i = 0;
while(*source)
{
*dest++ = *source++;
if(*source == token)
{
source++;
}
}
*dest++ = '\0';
}
int main(void)
{
char *long_name = "dog,sat ,on ,the,rug,in ,front,of,the,fire";
char buffer[sizeof(long_name)/sizeof(*long_name)];
stvstrtok(long_name, buffer, ',');
printf("buffer: %s\n", buffer);
getchar();
return 0;
}