Thread: Input Validation

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    5

    Input Validation

    Code:
    void BP::GetPressure()
    {        
        cout << "Please enter your Diastolic Pressure readings: ";
        cin >> firstDiastolic >> secondDiastolic >> thirdDiastolic;
        cout << "Please enter your Systolic Pressure readings: ";
        cin >> firstSystolic >> secondSystolic >> thirdSystolic;
        
    }
    Any input on how I can get firstDiastolic, secondDiastolic, thirdDiastolic, firstSystolic, secondSystolic, thirdSystolic to accept only positive integers? I am trying to use a while loop but am having trouble with implementing this with conditions on six variables.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Any input on how I can get firstDiastolic, secondDiastolic, thirdDiastolic, firstSystolic, secondSystolic, thirdSystolic to accept only positive integers?
    If this program isn't for a *very* serious purpose, just take the absolute value of whatever the user enters.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Let's see... what is the condition for when the input is valid?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Quote Originally Posted by Elysia View Post
    Let's see... what is the condition for when the input is valid?
    Blood pressure, how does it work?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    That was aimed at the OP, but just for the sake of it, I don't know the slightest of how it works.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Input/Validation
    By nokia123456 in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 11:26 AM
  2. input validation, kinda
    By dynamethod in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2008, 12:52 AM
  3. c++ strings. input validation
    By Crashgr in forum C++ Programming
    Replies: 2
    Last Post: 08-24-2004, 06:54 PM
  4. Input Validation!
    By noaksey in forum C Programming
    Replies: 2
    Last Post: 05-02-2004, 05:19 AM
  5. Input validation
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2001, 11:18 PM