Jump to content
  • Advertisement

Archived

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

acw83

String Woes

This topic is 6888 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

Advertisement
Look at cin.getline(). It reads in an entire line of input (upto a carriage return, line-feed, or a '\0'.) including spaces.

Share this post


Link to post
Share on other sites
I believe that cin terminates the terminates the string when it reached a CR, SPACE..etc.

Try using printf();

Share this post


Link to post
Share on other sites
I was just reading up on that. cin.getLine(string str) will get you a whole line of text. In fact, so will cin.get(char *str, int numChars) will get you <= numChars from the input stream. In that case you'd normally use 80 for numChars (80's the width of a normal dos window).
As far as STL stream documentation goes it is pretty scarce on my compiler help file system, and for that matter, in a lot of on-line STL tutorials/guides. Someone had a link in a previous post to the pre-print Thinking In C++ 2nd edition book that's in PDF format. I'm imagining that contains a lot of good reference of both STL and streams.

BTW, STL's pretty cool once you get the hang of it.

JoeG

[This message has been edited by joeG (edited December 15, 1999).]

Share this post


Link to post
Share on other sites
Look at my code for an echo program...

#include
#include

void hello(char* Super)
{
for(int index = 0;index<256;index++)
cout<};

void main()
{
char* Super;
Super = new char[256];
memset (Super,32,sizeof(char)*256);
cout<<"Input somethin fo my ass to repeat\n:";
cin>>Super;
hello(Super);
delete Super;
}

Everything works, except when the user types in spaces(null terminators or something...) How do I make it work if for example the user inputed: "Yo, wassup my main man?"

THANKS!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!