Spaces in Console
yea I know a noob question, I know its not string, int, char didn''t work what the hell is it???
Easy way of programming: Code, Graphics, Swearing....
std::cout << '' '';
???Craaazzzy boy. :/
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
//all teh crap above...void main(){??? name;cout << "Enter name: ";cin >> name;cout << name;}see whats the varible...
Easy way of programming: Code, Graphics, Swearing....
std::cout << "Enter name: ";
char name[20];
std::cin >> name;
std::cout << "Your name is " << name << ''\n'';
yet I would recommend:
std::cout << "Enter name: ";
std::string name;
std::cin >> name;
std::cout << "Your name is " << name << ''\n'';
There are, though, a number of different approaches.
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
its not working.... lol U put in bob smith
out comes bob...
whats wrong here
[edited by - XDarkScar on April 18, 2003 2:16:58 PM]
out comes bob...
whats wrong here
[edited by - XDarkScar on April 18, 2003 2:16:58 PM]
omg I said it wrong..... Mean takes spaces like bob smith out comes bob smith
Easy way of programming: Code, Graphics, Swearing....
Easy way of programming: Code, Graphics, Swearing....
If you are using
or, if not:
It is to do with input streams (buffers); have a look on Google for more.
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[edited by - Lektrix on April 19, 2003 10:11:19 AM]
std::string
:
std::cout << "Enter name: ";
std::string name;
std::getline(std::cin, name, '\n');
std::cout << "Your name is " << name << std::endl;
or, if not:
std::cout << "Enter name: ";
char name[20];
std::cin.getline(name, 20);
std::cout << "Your name is " << name << std::endl;
It is to do with input streams (buffers); have a look on Google for more.
[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[edited by - Lektrix on April 19, 2003 10:11:19 AM]
K, do you know how to speak english well? do you know how to articulate a question well?
do you mean "bob smith " becomes "bob smith"? i.e. trailing whitespace is being eliminated?
do you mean "bob smith " becomes "bob smith"? i.e. trailing whitespace is being eliminated?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement