POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: A test Server Time
1 Oct 2024 07:21:16 EDT (-0400)
  Re: A test  
From: Orchid XP v8
Date: 21 Sep 2008 04:43:06
Message: <48d6091a$1@news.povray.org>
Warp wrote:
> Orchid XP v8 <voi### [at] devnull> wrote:
>>      std::string  txt;
>>      std::cin  >> txt;
> 
>>      std::istringstream iss(txt);
>>      int number;
>>      iss >> number;
> 
>   I think you misunderstood the reason to use stringstreams.

Er, yeah, good point...

>>      if (number < target) {std::cout << "Too low."  << std::endl; continue;}
>>      if (number > target) {std::cout << "Too high." << std::endl; continue;}
>>      break;
> 
>   Wouldn't it be simpler to do it like:
> 
>     if(number == target) break;
>     if(number < target) std::cout << "Too low.\n";
>     else std::cout << "Too high.\n";

Mmm, I guess that would also work...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

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