Hello. I am trying to validate a customer number using isdigit. If the user accidently enters a character other than an integer, I want it to allow the user to try again. The problem is it only will check the first number and if that is a digit it it presumes it is ok. I want it to check all the numbers entered. I have it currently looping around the whole thing so I can keep testing input. Thank you (in anticipation)
#include "stdafx.h"
#include <iostream>
#include <cctype>
#include <iomanip>
using namespace std;
int main()
{
char password [6]; //password is 6 digit long
int i;
cout << "enter your login : " ;
cin >> password;
for (i = 0; i < 6; i++)
{
if (isdigit (password[i]))
{cout << "\nThank you." << endl;}// it is an integer yay!
else
cout << "\nYou can only have a numeric login" << endl;
cout <<"Enter your login: " << endl;
cin >> password;
}
system("pause");
return 0;
}