Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. int menu_counter = 0;
  2.     cout << " ENTER THE BOOK ISBN:   ";
  3.     // Let the User enter in Book ISBN...
  4.     getline(cin, book_isbn);
  5.     //cout << "book length is:  " << book_isbn.length() << endl;
  6.     // Let's loop through the ISBN string to check if there are any normal letters instead of just numbers.
  7.     cout << "The string is " << book_isbn.empty() << endl;
  8.     for (int i = 0; menu_counter < book_isbn.size(); i++)
  9.     {
  10.         //cout << isdigit(book_isbn[menu_counter]) << endl;
  11.         int result_test = isdigit(book_isbn[menu_counter]); // The Result of if the Position is a Digit or not
  12.         // If the Digit is 0, then that means we came across a letter, and the user must start over.
  13.         if (result_test == 0)
  14.         {
  15.             if (book_isbn[menu_counter] == '-')
  16.             {
  17.                 menu_counter++; // Let's increase the menu counter to check more of the string...
  18.             }
  19.             else
  20.             {
  21.                 //cout << endl;
  22.                 cout << "Please re-enter the ISBN Number:  ";
  23.                 getline(cin, book_isbn);
  24.             }
  25.         }
  26.         if (book_isbn.empty())
  27.         {
  28.             //cout << endl;
  29.         cout << "Please re-enter the ISBN Number:  ";
  30.             getline(cin, book_isbn);
  31.         }
  32.         if(result_test != 0 && book_isbn.empty() != 1)
  33.         {
  34.             menu_counter++; // Let's increase the menu counter to check more of the string...
  35.         }
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement