🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

String Woes

Started by
4 comments, last by acw83 24 years, 6 months ago
the included files were omitted due to HTML crap, anyway, they were memory.h and iostream.h
Advertisement
Look at cin.getline(). It reads in an entire line of input (upto a carriage return, line-feed, or a '\0'.) including spaces.
I believe that cin terminates the terminates the string when it reached a CR, SPACE..etc.

Try using printf();

William Reiach - Human Extrodinaire

Marlene and Me


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

joeG
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!

Thanks for the help everyone!

This topic is closed to new replies.

Advertisement