Something along this line?
Code:
#include <stdio.h>
#include <string.h>
int main()
{
const char example[] = "aj df qww xa df ao aj df qww";
const char first[7], *start = example, *match, *ptr;
while ( sscanf(start, "%6s", first) == 1 )
{
size_t len = strlen(first);
printf("first = \"%s\"\n", first);
if ( !start[len] )
{
break;
}
start += len + 1;
ptr = start;
while ( match = strstr(ptr, first) )
{
printf(" match = \"%s\"\n", match);
ptr = match + 3;
}
}
return 0;
}
/* my output
first = "aj"
match = "aj df qww"
first = "df"
match = "df ao aj df qww"
match = "df qww"
first = "qww"
match = "qww"
first = "xa"
first = "df"
match = "df qww"
first = "ao"
first = "aj"
first = "df"
first = "qww"
*/