Is there a way to check a string for a space
If you read my other thread you know that I am making a character creation program to assist my cousins program. 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 (All the cause of a infinite loop as far as i can tell). Here is the PORTION of code that is causing the error.
Really I need to know if there is a way to check input for spaces to prevent incorrect input.
NOTE that this is just part of my program if you want the entire thing just ask and I can send the .cpp and accompaning files.
Code:
switch ( a[2] ) {
case 1:
cout <<"Ok, This Is The Easiest Step. Simply Type In The Name You Want.\n";
cout <<"Type Name: (NO SPACES)";
cin >>name[1];
cin.ignore();
cout.flush();
cout <<"You Entered // "<< name[1] <<" // as your name.\n";
cout <<"If your name is incorrect just go to character menu again and change it.\n";
cout <<"Press ENTER to return to character menu\n";
z[2] = 1;
cin.get();
break;
Well if you see my problem and see a possible solution Hopefully you share it. THANK YOU ALL IN ADVANCE.