Re: build warnings
- From: Paul Russell <prussell@xxxxxxxxx>
- Date: Fri, 19 May 2006 17:19:44 +0100
Paul wrote:
"Paul Russell" <prussell@xxxxxxxxx> wrote in message
news:4d5aikF18fr8kU2@xxxxxxxxxxxxxxxxx
adrian.bartholomew@xxxxxxxxx wrote:
whats wrong with this?
stringTemp[strlen(string)] = NULL;
NULL is a pointer, not a char.
Try this:
stringTemp[strlen(string)] = '\0';
Paul
I hope this isn't from actual code...
Assuming that what you want to do is write the null terminator byte on
stringTemp,
stringTemp[strlen(string)]
is indeed that byte (since the first byte is stringTemp[0] ), but strlen()
will not work (will probably crash, in fact) unless the final byte is 0
already, making it pointless to write it again.
Another Paul
Look again - it's two different strings: stringTemp and string.
And yes, it's horrible code - but everyone's got to start /somewhere/.
The First Paul
.
- Follow-Ups:
- Re: build warnings
- From: Paul
- Re: build warnings
- References:
- build warnings
- From: adrian . bartholomew
- Re: build warnings
- From: Paul Russell
- Re: build warnings
- From: Paul
- build warnings
- Prev by Date: Re: build warnings
- Next by Date: Re: build warnings
- Previous by thread: Re: build warnings
- Next by thread: Re: build warnings
- Index(es):
Relevant Pages
|
|