Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
On Sun, 1 Jul 2007, Stephen Montgomery-Smith wrote:
Also you might want to look at the function strstr instead of regexec. For
what you are wanting to do, it looks a lot simpler. So suppose you are
looking for the third occurence of "ABC" in "XXABCXXABCXXABCXXX":
char *s, *t, *u;
strcpy(s,"ABC");
strcpy(t,"XXABCXXABCXXABCXXX");
u = strstr(t,s);
if (u!=NULL) u = strstr(u,s);
if (u!=NULL) u = strstr(u,s);
if (u!=NULL) printf("%d\n",u-s); else printf("Not found");
although this code fragment is totalyl buggy because I forgot to allocate
space to s and t, so
char s[]="ABC";
char t[]="XXABCXXABCXXABCXXX";
char *u;
etc etc
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members