ok have gotten this far now. now I cant get my loop to work correct. anyone help I bad at loops.
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
char strVal; // The user entered string
string input;
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;
}
cin >> strVal;
if(inValid)
cout << strVal << " is not a binary number." << endl;
else
cout << strVal << " 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).