Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

XDarkScar

Spaces in Console

This topic is 5719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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....

Share this post


Link to post
Share on other sites
Advertisement

//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....

Share this post


Link to post
Share on other sites
And what does this have to do with a space???

What makes you think it''s not string?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
omg I said it wrong..... Mean takes spaces like bob smith out comes bob smith

Easy way of programming: Code, Graphics, Swearing....

Share this post


Link to post
Share on other sites
If you are using 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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!