/* * @topic T00264 string input and validation using 2 source files * @brief main function is defined here */ /* This is our second prototype for homework Assignment that deals with binary to hex conversion. Same capabilities as in previous sample, but this program is using multiple source files. The program below can input and validate user input. The work is done in separate functions. The main() function makes calls to delegate tasks to other functions. The program also shows how you can display numbers in hexadeciam or decimal format. */ // Include our own header file #include "user_input.h" // program begins here: int main() { std::string str_bin_num; // Until the user enters a binary number correctly, // keep asking for input: for(;;) { // forever -- endless loop // get user input: str_bin_num = get_user_input( "Enter a bin #>" ); // validate user input: if ( validate_user_input( str_bin_num ) ) { // everything is okay, break; // exit the loop } else { std::cout << "bad input! please retry\n"; } }//for std::cout << "You typed: " << str_bin_num << '\n'; // The rest of this demo shows how to int value = 0x5A7BF; // specify hex number in your program std::cout << std::hex << value << '\n'; // display the hex number std::cout << std::dec << value << '\n'; // display the decimal number return 0; }