I have some code: I wish to take in an ID, make sure it's of 8 chars in length, make sure each digit is a number, and continue to ask until they give the correct input. BEFORE SOMEONE MARKS THIS DOWN, i researched and tried to look at answers given :c I don't get why it says the id I enter 00000002 is an Invalid ID according to my code. It's not working. can anyone help?
void Student::getData(){
string id_;
cout << "lastName?" << endl;
cin >> lastName;
cout << "firstName?" << endl;
cin >> firstName;
cout << "ID?" << endl;
while(getline(cin,id_) && id_.size() != 8){
cout << "Invalid ID" << endl;
}