limited input with Getline

I'm using getline to input information into strings from a user, and I want only a specific amount of characters. Would you guys show me how to do this?

Using

 
getline(cin, wiz0.mName);


I can get the entire character's name, and I'd like to learn how to set a character limit.
1
2
wiz0.mName.length() //number of charecters in this string
wiz0.mName.erase(N); //erase all charecter at pos N and beyond 

http://www.cplusplus.com/reference/string/string/length
http://www.cplusplus.com/reference/string/string/erase
Last edited on
If you just need to adjust it after it has been extracted from the stream (and I think that's just what you need), that's ok. If you want to extract just that number of characters, you have to use istream::get.
Topic archived. No new replies allowed.