strstr and strchr
Fundu <[email protected]>
| Newsgroups | org.kernel.vger.linux-c-programming |
|---|---|
| Message-ID | <[email protected]> |
looks strange to me
if i look for a str using strstr it gives me the starting index of the string. so let say if i'm looking for "firstName" in "<Info firstName=\"sam\" lastName=\"Smith\" />" using
strstr(ptr, "firstName"); i would get the pointer pointing to the f in firstName.
whereas if i use strchr and using a slight variation of the string mentioned above(suing ' instead of ") "<Info firstName='sam' lastName='Smith'/>"
strchr(ptr, "'") returns a pointer pointing after the '
so a printf("[%s]\n", strchr(ptr, "'"));
would print [ lastName='Smith'/>]
which doesn't make sense to me.
can someone shed some light. TIA !