Is there a reason you want to limit the user to entering one word names? Variables of type string (#include <string>) do not have a limit on the size of the string they can contain. Here is an example:
Now I ran into a problem of if when asking user to input preferred name. If they put a space the porgram either uses allof my memory or crashes OR locks up my computer
You can use a different form of getline() than SlyMaelstrom posted to read data into a string type:
string str = "something";
str = "Something a little longer.";
'source' can be 'cin' or a file. getline() will read in data until it encounters a '\n'. Or, if you need to read in multiple lines into one variable, you can specify a character to signal when to stop reading as the 3rd paramter of getline() e.g.:
That will keep reading in data until a '#' character is encountered in the input source.
getline(source, str, '#');