I have an object with a std::string field notes that allows a maximum of 100 chars. I need to write a C++ console interface (using IOStream) to let the user input these notes. All characters are allowed, including of course spaces.
What’s the best way of doing such thing?
Is there a way to let the user know how many characters are left?
EDIT: Also empty string should be allowed
Use
std::stringandstd::getline.You can display one hundred asterisks this way:
then, with a sufficiently wide console window, the user can see how much space remains.