This partial code check for specific format in char array.
char emp_id[10];
cout<<"Employee ID\t\t: ";
while(cin.getline(emp_id,10)) {
if (emp_id[0] == 'e' || emp_id[0] == 'E'){
break;
}
std::cout << "Input error. Invalid employee ID format." << std::endl;
cout<<"\nEmployee ID\t\t: ";
}
The accepted format is e<employee ID number>. For example: e3 or E59. Any letter after e are not accepted such as Eg, e56h, e77$ etc. etc.
I manage to check whether the first letter in array is e or E with the above code. Then I didn't know how to check for invalid format such as Eg or e56h. If this question had been asked before please point me to the answer page because I'm not sure what search keyword should I use. Please help me and thanks in advance.