The easy way is to use getline(cin,name) where name is a std::string. If, for some reason the first 49 characters are the only ones that are significant you can use resize(). If you must make life difficult for yourself
Code:
// Leave newline in stream, regardless of
// success, then use ignore to discard
// any extra(plus the newline).
cin.get(name,50);
cin.ignore(numeric_limits<int>.max(),'\n');
// Check the status of failbit, if true discard
// any characters in the buffer up to and
// including newline
if(!cin.getline(name,50)) {
cin.clear();
cin.ignore(numeric_limits<int>().max(),'\n');
}
The first version is simpler, but doesn't give you a chance to perform any extra processing if the line was too long for your buffer. With the second you have a chance to react to the excessive input in a more constructive manner.