Re: A89: Clearing a string


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

Re: A89: Clearing a string




you right... you are wrong :> (that make sense to anyone). I compiled
some c into assembly to check and in fact it is not that arrangement.

 expr1
loop:
 if expr2 then jump to expressions else jump out
 expressions
 expr3
 jump loop
out:

Olle Hedman wrote:
> 
> 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

-- 
Scott "Wrath" Dial
wrath@calc.org
ICQ#3608935
Member of TCPA - tcpa.calc.org

____________NetZero Free Internet Access and Email_________
Download Now     http://www.netzero.net/download/index.html
Request a CDROM  1-800-333-3633
___________________________________________________________



References: