POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: My first C++ program Server Time
4 Nov 2024 19:15:51 EST (-0500)
  Re: My first C++ program  
From: Orchid XP v8
Date: 21 Sep 2008 12:26:26
Message: <48d675b2@news.povray.org>
Warp wrote:

>   The above example code can thus be written as:
> 
>     while(true)
>     {
>         int value;
>         std::cin >> value; // Try to read an integer
>         if(std::cin.fail()) // If there was no integer in the input
>         {
>             std::cin.clear(); // Clear the error flags
>             std::string s;
>             std::cin >> s; // Read a string
>             if(!std::cin.good()) break;
>             std::cout << "The input was something else: " << s << "\n";
>         }
>         else
>         {
>             std::cout << "The input was an integer: " << value << "\n";
>         }
>     }
> 
>   Thus removing the need for stringstreams.

This doesn't appear to work. It waits for me to type a second token, and 
then works with that. (Either that or my program has some other random 
bug... If I ever figure out how to work VisualStudio's debugger I'll let 
you know!)

-- 
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.