No, do not use gets(), ever! [edit] It is a bad, dangerous function -- even though it is in the standard library.[/edit]
There are several issues to getting input, but the foremost is that the user will always press ENTER after every input. Therefore, make sure that your inputs account for that.
When you get a number, use something like:
1 2 3 4
int n = 7; // (or whatever your default value is)
cin >> n; // try to get the number
if (!cin) cin.clear(); // recover from errors
cin.ignore( numeric_limits <streamsize> ::max(), '\n' ); // get rid of the ENTER key
When you get a string, use something like:
1 2
string s;
getline( cin, s ); // reads the entire line of input and gets rid of the ENTER key
Never use gets(). Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security.
Why would it be dangerous if you have to insert the buffer size? If besides that it still has security problems that's all another thing. But inserting the buffer size in an "input" isn't a negative thing.
I'm not sure why you are having such a hard time understanding me. If you are just trolling then you should know right now that I don't intend to post again on this topic, so you might as well give up now. If not, you should look back and see if you can find exactly where it was that I suggested that gets_s() is dangerous. (You can't, because I very explicitly answered that it was not -- this makes three times now.)
from what i understanded , u want the program to accept the space or to prevent user from hitting space ? well lemme try to code some
cin >> x
if (x != " ")
or ummm if character length != 6*2 or 6*4 ?