Are you sure?

StrLen depends on the '\0' to do its job.  That string is not null-terminated
and you cannot use it.

Although it may be true that the code encounters a NULL with more chance than a
'\n' in the RAM, it dooms to fail every time when there is no '\0' after the
'\n'. :)

Max
--- Dave Lippincott <[EMAIL PROTECTED]> wrote:
> even easier...
> string[strlen(string)-1] = '\0';
> Your method could over-bound the string and blow up if the '\n' is missing.
> 
> ----- Original Message -----
> From: "Max Bian" <[EMAIL PROTECTED]>
> To: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Sent: Friday, January 04, 2002 9:02 AM
> Subject: Re: String without \n......
> 
> 
> > StrChr is the function you may need.
> >
> > Or simply:
> >
> > char *strP = String;
> > while(*strP != '\n') strP++
> > *strP = '\0';
> >
> > Max
> > --- palm <[EMAIL PROTECTED]> wrote:
> > > Hi
> > >
> > > I've got following problem:
> > >
> > > the string which I get back form a routine has a \n at the end....but I
> need
> > > a \0 for my search.
> > > e.g. "00000103\n" -> "00000103\0"
> > >
> > > Thanks.
> > >
> > > Sebastian
> > >
> > >
> > >


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to