Re: strstr and strchr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bert,
i did try that but got same response. 


--- On Tue, 2/17/09, Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx> wrote:

> From: Bert Wesarg <bert.wesarg@xxxxxxxxxxxxxx>
> Subject: Re: strstr and strchr
> To: fundu_1999@xxxxxxxxx
> Cc: linux-c-programming@xxxxxxxxxxxxxxx
> Date: Tuesday, February 17, 2009, 2:48 AM
> On Tue, Feb 17, 2009 at 09:30, Fundu
> <fundu_1999@xxxxxxxxx> 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 !
> --
> To unsubscribe from this list: send the line
> "unsubscribe linux-c-programming" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at 
> http://vger.kernel.org/majordomo-info.html


      
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux