title: I need help in my C++ ATM machine code, about filtering out characters or strings
body: <p>I would really not ask if I really know the answer. New to c++ and all I know is here, it's also in Trial and error situation but trying to beat the deadlines, This is a homework. The problem I am encountering now is when a user inputs a char or string, I can't seem to find the solution to filter it out and prompt to "key in again due to invalid input." .. Any ideas? the char seems to value on 0. Tried to key in conditions regarding to that but still not working. Don't know what to do with this.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  using namespace std;
  
  /*--------------------------------------------------
  ---------------------------------------------------------
  Accounts are under pinnumbers:                           |
  1001 increment of 1                                      |
  Passcodes are under the codes:                           |
  1101 increment of 1                                      |
                                                           |
  limit of 10 as instructed.                               |
                                                           |
  i.e : (valid pin number ) 1001 = (valid pin code) 1101   |
  ---------------------------------------------------------
  */
  
  int option, pinnumber, pincode, vip[10], pc[10], money[10], accountno[10], getindex;
  string name[10]; 
  void mainmenu();
  void assignaccounts();
  void checkaccounts();
  void start();
  void options();
  bool logged=false;
  char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
  
  
  //&lt;--START OF THE MAIN FUNCTION --&gt;
  main() {       
  
  assignaccounts();
  start();                      
  system("PAUSE"); //more of a getch() pero naa xa'y press any key. w/c is better!
  }
  
  //&lt;--EOF MAIN FUNCTION--&gt;
  
  //&lt;-- START OF EXTRA FUNCTION SECTION --&gt; 
  //---Start of checkaccounts function --&gt; -----------------------------
  void checkaccounts() {                                              //|
          for(int x=0; x&lt;10; x++) {                                   //|
            if(( vip[x] == pinnumber)  &amp;&amp; ( pc[x] == pincode  )) {    //|
              logged=true;                                            //|
              getindex=x;                                             //|
              mainmenu();                                             //|
              break;                                                  //|
           } else if ((pinnumber == 'a') &amp;&amp; (pincode == 'A' )) {
             cout&lt;&lt;"Invalid Input, Try again."&lt;&lt;endl;
             cin.clear();
             main();
             break;   
           } else {
             ;
           }                                                         //|                                                        
          }                                                           //|
          if(!logged){                                                //|
                 cout&lt;&lt;"\n\t Invalid Input, Try again."&lt;&lt;"\n\n\t ";   //|
                 system("PAUSE");                                     //|
                 start();                                             //|
          }                                                           //|
                                                                      //|                                                                   
  }                                                                   //|
  //end of checkaccounts function --------------------------------------
  
  
  //Start of Assignaccounts function------------------------------------
  void assignaccounts() {                                             //|
         for(int x=0; x&lt;10; x++) {                                    //|
           vip[x]=1001+x;                                             //|
           pc[x]=1101+x;                                              //|                                                         
          }                                                           //|
     name[0] = "John Do Doe";                                         //|
     money[0] = 10000;                                                //|
     accountno[0] = 1;                                                //|
                                                                      //|
     name[1] = "Zsaza Pa Ligid";                                      //|
     money[1] = 20000;                                                //|
     accountno[1] = 2;                                                //|
                                                                      //|
     name[2] = "Robin Pa Didit";                                      //|
     money[2] = 30000;                                                //|
     accountno[2] = 3;                                                //|
                                                                      //|
     name[3] = "lrem ipm";                                            //|
     money[3] = 40000;                                                //|
     accountno[3] = 4;                                                //|
                                                                      //|
     name[4] = "Daniel Pa Slide";                                     //|
     money[4] = 50000;                                                //|
     accountno[4] = 5;                                                //|
                                                                      //|
     name[5] = "James Bond";                                          //|
     money[5] = 60000;                                                //|
     accountno[5] = 6;                                                //|
                                                                      //|
     name[6] = "Lara Croft Llara";                                    //|
     money[6] = 70000;                                                //|
     accountno[6] = 7;                                                //|
                                                                      //|                                                                 
     name[7] = "John Ziggy Pa ( GOLD MEMBER )";                       //|
     money[7] = 90000;                                                //|
     accountno[7] = 11;                                               //|
                                                                      //|
     name[8] = "Loren Joy Chris ( GOLD MEMBER )";                     //|
     money[8] = 110000;                                               //|
     accountno[8] = 10;                                               //|
                                                                      //|
     name[9] = "Jayson Derulo";                                       //|
     money[9] = 120000;                                               //|
     accountno[9] = 10;                                               //|
                                                                      //|
  }                                                                   //|
  //End of Assignaccounts function--------------------------------------
  
  
  //---Start of start function --&gt; -------------------------------------
  void start() {                                                      //|           
       system("cls");                                                 //|
       cin.clear();
       cout&lt;&lt;"------------------------------------------"&lt;&lt;endl;      //|
       cout&lt;&lt;" |** WELCOME TO CAMARILLO &amp; ALJON ATM **|"&lt;&lt;endl;       //|
       cout&lt;&lt;"------------------------------------------"&lt;&lt;endl;      //|
       cout&lt;&lt;"\nEnter valid identification pin number (VIP): ";       //|
       cin&gt;&gt;pinnumber;                                                //|
       cout&lt;&lt;"\nEnter valid pincode (PC): ";                          //|
       cin&gt;&gt;pincode;                                                  //|
       checkaccounts();                                               //|
                                                                      //|
  }                                                                   //|
  //end of Start function ----------------------------------------------
  
  
  //start of mainmenu function ----------------------------------------------------------------------------------
  void mainmenu() {                                                                                           // |
       int choice;                                                                                            // |
       if(logged) {                                                                                           // |
        while(true){                                                                                          // |
           system("cls"); //clearscreen                                                                       // |
           cout&lt;&lt;"Log-in successful!"&lt;&lt;endl;                                                                  // |
           cout&lt;&lt;"\nWelcome: "&lt;&lt;name[getindex];                                                                // |
           cout&lt;&lt;"\nAccount No.: "&lt;&lt;accountno[getindex]&lt;&lt;endl;
           cout&lt;&lt;"\nChoose a Transaction:\n";                                                                 // |
           cout&lt;&lt;"\n";                                                                                        // |
           cout&lt;&lt;"[1] Inquire Balance \n"                                                                     // |
           &lt;&lt;"[2] Withdraw \n"                                                                                // |
           &lt;&lt;"[3] Deposit \n"                                                                                 // |
           &lt;&lt;"[4] Quit \n"                                                                                    // |
           &lt;&lt;"\n"&lt;&lt;endl;                                                                                      // |
           cout&lt;&lt;"Enter Option: ";                                                                            // |
           cin&gt;&gt;option;                                                                                       // |
                                                                                                              // |
            if (option == 1) {                                                                                // |
              cout&lt;&lt;"\n\tOutstanding Balance is P"&lt;&lt;money[getindex]&lt;&lt;"\n\n\t ";                               // |
              system("PAUSE");                                                                                // |
           } else if (option == 2) {                                                                          // |
             int co;                                                                                          // |
             cout&lt;&lt;"\n\tEnter amount: ";                                                                      // |
                   cin&gt;&gt;co;                                                                                   // |
                   if(co&lt;money[getindex]){                                                                    // |
                      money[getindex]-=co;                                                                    // |
                      cout&lt;&lt;"\n\tYour Outstanding Balance has been updated to P"&lt;&lt;money[getindex]&lt;&lt;"\n\n\t "; // |
                   } else {                                                                                   // |
                      cout&lt;&lt;"\n\t Invalid amount, Please check again.";                                       // |
                      cout&lt;&lt;"\n\t You only have P"&lt;&lt;money[getindex]&lt;&lt;" in your account."&lt;&lt;"\n\n\t ";          // |
                   }                                                                                          // |
                   system("PAUSE");                                                                           // |
           } else if (option == 3) {                                                                          // |
             int dep; //Declaration of the cin in this case;                                                  // |
                   cout&lt;&lt;"\n\tEnter amount: ";                                                                // |
                   cin&gt;&gt;dep;                                                                                  // |
                   money[getindex]+=dep;                                                                      // |
                   cout&lt;&lt;"\n\tYour Outstanding Balance has been updated to P"&lt;&lt;money[getindex]&lt;&lt;"\n\n\t ";    // |
                   system("PAUSE");                                                                           // |
           } else if (option == 4) {                                                                          // |
             break;                                                                                           // |
           } else{                                                                                            // |
                 cout &lt;&lt; "\n\n\tInvalid Input, Try again.\n\n\t ";                                            // |
                 system("PAUSE");                                                                             // |
           }                                                                                                  // |
        }                                                                                                     // |
           cout&lt;&lt;"\n\n\t THANK YOU FOR USING OUR ATM, YOU'LL NOW EXIT THE PROGRAM."&lt;&lt;endl;                    // |
           cout&lt;&lt;"\n\t This is intended for our project in c++ under Professor Machica."&lt;&lt;"\n\n\t ";          // |                                                 
       }                                                                                                      // |                                                                                                          // |
  }                                                                                                           // |
  //end of mainmenu function-------------------------------------------------------------------------------------
  
  //&lt;-- EOF EXTRA SECTION FUNCTIONS--&gt;
  </code></pre>