single loop copy in D

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Mar 2 10:01:34 UTC 2018


On Friday, March 02, 2018 09:44:20 psychoticRabbit via Digitalmars-d-learn 
wrote:
> trying to do this C code, in D, but getting error:
> "Error: assignment cannot be used as a condition, perhaps `==`
> was meant?"
>
> any help much appreciated:
>
> ------
> while ((*dst++ = *src++)) {}
> ------

You can't use = in a while loop's condition like that in D, regardless of
what you do with parens. You'll need to refactor the code so that the
assignment is done in the loop's body.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list