Re: A89: Clearing a string
[Prev][Next][Index][Thread]
Re: A89: Clearing a string
Nope, it will work. a for statement makes the following code:
for(expr1; expr2; expr3) {
expressions;
...
}
makes a loop like this (in pseudocode):
expr1
loop:
expressions
...
expr3
if expr2 goto loop
//Olle
ComAsYuAre@aol.com wrote:
>
> I don't think yours will actually work though--it won't clear the first char. Rather, use:
>
> for(int i=0; str[i]; str[i++]=0);
>
> If you post-increment i in the conditional, it will test before the first loop and thus skip str[0] in the clearing code. Incrementing in the "increment" piece of the for loop generally works better =P
//Olle
Follow-Ups:
References: