linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* strstr and strchr
@ 2009-02-17  8:30 Fundu
  2009-02-17 10:48 ` Bert Wesarg
  0 siblings, 1 reply; 5+ messages in thread
From: Fundu @ 2009-02-17  8:30 UTC (permalink / raw)
  To: linux-c-programming

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 !


      

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-17 12:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-17  8:30 strstr and strchr Fundu
2009-02-17 10:48 ` Bert Wesarg
2009-02-17 11:52   ` Fundu
2009-02-17 11:58     ` Bert Wesarg
2009-02-17 12:00       ` Bert Wesarg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).