CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    26

    How to check that CIN recieves correct data types?

    What I'm wondering is pretty simple, but I have no idea how to do it the right way or how many ways there are to do it.

    Say I want a user to input a number, but if the user inputs something else than a number it breaks my program. How do I succeed in checking that the input is correct with CIN?

    I've tried using typedef/id/name but I guess it's used for Templates, so I'm out of luck.

    Is there any inbuilt class that does this, or how do I make it myself?

    Any help is appreciated.

    Thanks!

  2. #2
    Join Date
    Aug 2007
    Posts
    858

    Re: How to check that CIN recieves correct data types?

    Check the stream for failure. See

    http://www.parashift.com/c++-faq-lit....html#faq-15.2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured