in the reference for operator>> http://cplusplus.com/reference/iostream/istream/operator%3E%3E/ , there is an example when they limit the size of the word read in input by using cin.width (unsignedint i). maybe you can try that. Otherwise, maybe the iostream::get function could be used in your case.