Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   A doubt regarding a Piece of code!!! ple. help (http://www.go4expert.com/forums/doubt-regarding-piece-code-ple-help-t25617/)

vikky1988i 25Apr2011 12:13

A doubt regarding a Piece of code!!! ple. help
 
Hello all,
I have a problem in understanding a basic thing in this code!!!

while(*src++ = *des++);

seems to run infinitely since no condition here , but in real this works fine.... just need a explanation for this.. how does the compiler interprets this!!! please :snobby::embarasse:worried:

xpi0t0s 26Apr2011 22:48

Re: A doubt regarding a Piece of code!!! ple. help
 
while takes a boolean, so when *src++=*des++ evaluates to zero, the loop will terminate. The value of an expression is the assigned value, so for example if taken in a value context, the value of "a=5" is 5. So this also means you can do something like a=b=c=d=e=3; which will set all variables to the same value.


All times are GMT +5.5. The time now is 22:02.