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
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:
Code:
string str = "something";
cout<<str<<endl;
str = "Something a little longer.";
cout<<str<<endl;
You can use a different form of getline() than SlyMaelstrom posted to read data into a string type:
Code:
getline(source, str);
'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.:
Code:
getline(source, str, '#');
That will keep reading in data until a '#' character is encountered in the input source.