Can anyone help me fix this problem I have in my program it keeps displaying the same cout statement no matter what output.
Code:// InvalidBinDr.cpp #include<iostream> #include<string> #include<cctype> using namespace std; // FILL IN InvalidBin PROTOTYPE: int main() { // Variables local to main bool inValid=true; // True if an invalid binary # is entered string input;// The user entered string while (true) { cout << "Enter a binary number (8 digits or less): "; getline(cin, input); if (input.size() <= 8) break; cerr << "You entered more than 8 digits. Please re-enter your number." << endl; } if(inValid) cout << input << " is not a binary number." << endl; else cout << input << " is a binary number." << endl; return 0; } // FUNCTION InvalidBin RETURNS TRUE IF THE STRING ENTERED BY THE // USER DOES NOT REPRESENT A VALID 8-BIT BINARY NUMBER OTHERWISE // IT RETURNS FALSE, (i.e. the string has 8 bits that are 1's or // 0's only).



LinkBack URL
About LinkBacks


