POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 1-5 Server Time
29 Jul 2024 22:30:57 EDT (-0400)
  Re: Days 1-5  
From: Alain
Date: 19 Apr 2012 21:38:13
Message: <4f90be05@news.povray.org>


>> is a perfectly valid statement in C++. On the other hand, it also means that
>
>>     while (x[i] = y[i--]) ;
>
>> is perfectly valid. You sick, sick people.
>
>    I think that's Undefined Behavior because the same variable is being
> modified and referenced more than once in the same expression.
>

Nothing undefined here.

It's a simple loop that compare the array x[] and y[] untill it find a 
value that is different.
You get the value of x[i] and see if it's the same as the value of y[i] 
then you decrement i by one.
On exit, i will point to the value preceding the first different value.

You must initiate i to the last valid index of your array.
If all elements of both arrays are the same, you can realy screw things, 
so you beter make sure that the elements zero are different.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.