Dividing String into substrings

Hello, i need to divide 1 AnsiString like "s0 s1 s2" into some substrings like "s0","s1","s2", but i have problem with it. Advice me how to do it,please.
Maybe you can try to modify this program to yours.

#include <stdio.h>
#include <string.h>
int main(int argc,char **argv)
{
char *haystack="aaa||a||bbb||c||ee||";
char *needle="||";
char* buf = strstr( haystack, needle);
while( buf != NULL )
{
buf[0]='\0';
printf( "%s\n ", haystack);
haystack = buf + strlen(needle);
/* Get next token: */
buf = strstr( haystack, needle);
}
return 0;
}

PS:i am a beginner,magbe i'm wrong,but just want to help.
Last edited on
Topic archived. No new replies allowed.