Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int menu_counter = 0;
- cout << " ENTER THE BOOK ISBN: ";
- // Let the User enter in Book ISBN...
- getline(cin, book_isbn);
- //cout << "book length is: " << book_isbn.length() << endl;
- // Let's loop through the ISBN string to check if there are any normal letters instead of just numbers.
- cout << "The string is " << book_isbn.empty() << endl;
- for (int i = 0; menu_counter < book_isbn.size(); i++)
- {
- //cout << isdigit(book_isbn[menu_counter]) << endl;
- int result_test = isdigit(book_isbn[menu_counter]); // The Result of the Position is a Digit or not
- // If the Digit is 0, then that means we came across a letter, and the user must start over.
- if (result_test == 0)
- {
- // Check to see if there is a dash somewhere...
- if (book_isbn[menu_counter] == '-')
- {
- menu_counter++; // Let's increase the menu counter to check more of the string...
- }
- // If there is no dash, then the user entered in something completely different
- else
- {
- //cout << endl;
- cout << "Please re-enter the ISBN Number: ";
- getline(cin, book_isbn);
- }
- }
- if (book_isbn.empty())
- {
- //cout << endl;
- cout << "Please re-enter the ISBN Number: ";
- getline(cin, book_isbn);
- }
- if(result_test != 0 && book_isbn.empty() != 1)
- {
- menu_counter++; // Let's increase the menu counter to check more of the string...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement