linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bert Wesarg <bert.wesarg@googlemail.com>
To: fundu_1999@yahoo.com
Cc: linux-c-programming@vger.kernel.org
Subject: Re: strstr and strchr
Date: Tue, 17 Feb 2009 11:48:44 +0100	[thread overview]
Message-ID: <36ca99e90902170248y5ae1dc8heb5e4873429f3ae@mail.gmail.com> (raw)
In-Reply-To: <550170.9890.qm@web63402.mail.re1.yahoo.com>

On Tue, Feb 17, 2009 at 09:30, Fundu <fundu_1999@yahoo.com> wrote:
> 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 '
strchr() takes a int as second argument, not a 'char *', I suggest trying:

strchr(ptr, '\'')

> 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 10:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17  8:30 strstr and strchr Fundu
2009-02-17 10:48 ` Bert Wesarg [this message]
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=36ca99e90902170248y5ae1dc8heb5e4873429f3ae@mail.gmail.com \
    --to=bert.wesarg@googlemail.com \
    --cc=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).