POV-Ray : Newsgroups : povray.off-topic : You lose some... : Re: You lose some... Server Time
7 Sep 2024 03:22:25 EDT (-0400)
  Re: You lose some...  
From: andrel
Date: 5 Oct 2008 09:51:41
Message: <48E8C6BB.4040202@hotmail.com>
On 05-Oct-08 15:36, andrel wrote:
> On 05-Oct-08 6:42, Chris Cason wrote:
>> Slime wrote:
>>>>     for (unsigned int i=0; i<c.size(); i++)
>>>>       if (c[i]) out.append("1"); else out.append("0");
>>> This isn't the cause of your crash, but I recommend not squishing 
>>> your code together like that. Keep each statement on a separate line 
>>> and use brackets around anything that's not a single simple statement:
>>>
>>>     for ( unsigned int i = 0; i < c.size(); i++ )
>>>     {
>>>         if ( c[i] )
>>>             out.append( "1" );
>>>         else
>>>             out.append( "0" );
>>>     }
>>
>> If he wants brevity he could also code it like this:
>>
>>   for (int i = 0; i < c.size(); i++)
>>     out.append(c[i] ? "1" : "0");
>>
>> which is just as valid and avoids running the if/else together.
>>
> Didn't we code that more like out.append("0" + c[i]) just to confuse the 
> readers?

Been a long time since I actually did write sufficient amount of C. :( I 
think I meant the character constant '0' and not the string "0".


Post a reply to this message

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