linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fundu <fundu_1999@yahoo.com>
To: linux-c-programming@vger.kernel.org
Subject: strstr and strchr
Date: Tue, 17 Feb 2009 00:30:51 -0800 (PST)	[thread overview]
Message-ID: <550170.9890.qm@web63402.mail.re1.yahoo.com> (raw)

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 !


      

             reply	other threads:[~2009-02-17  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17  8:30 Fundu [this message]
2009-02-17 10:48 ` strstr and strchr Bert Wesarg
2009-02-17 11:52   ` Fundu
2009-02-17 11:58     ` Bert Wesarg
2009-02-17 12:00       ` Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=550170.9890.qm@web63402.mail.re1.yahoo.com \
    --to=fundu_1999@yahoo.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).