Lets say I got a dummy char array
char dummy[n]
I want to
cin >> dummy
But as you can see if input has more than n characters program will crash . So I wonder is there a way to get first n characters and ignore the rest ?
Lets say I got a dummy char array
char dummy[n]
I want to
cin >> dummy
But as you can see if input has more than n characters program will crash . So I wonder is there a way to get first n characters and ignore the rest ?
You can use getline
http://www.cplusplus.com/ref/iostrea...m/getline.html
Or you can do it the easy way, and just use std::string, and stop worrying about all the low-level, fixed size char array ickyness .
http://www.msoe.edu/eecs/cese/resources/stl/string.htm
Thnx!