Hello all, I have been given an assignment to accept an 8 digit id in the form of an integer. I was wondering if there is a way to limit the user's input, or to take in the first 8 numbers imputed by the user.
Something like if the user entered 123456789, I would only use 12345678 and disregard anything after 8.
Thanks:)
string buffer;
cout << "Enter an ID: "; cin >> buffer;
buffer = buffer.substr(0, 8); // I would only use 12345678 and disregard anything after 8.
stringstream ss;
ss << buffer;
ss >> x; // I will input the variable x