Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

String Woes

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 acw83   Members   

174
Like
Likes
Like

Posted 15 December 1999 - 08:18 AM

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!


#2 acw83   Members   

174
Like
Likes
Like

Posted 14 December 1999 - 05:33 PM

the included files were omitted due to HTML crap, anyway, they were memory.h and iostream.h

#3 mhkrause   Members   

122
Like
Likes
Like

Posted 14 December 1999 - 05:38 PM

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

#4 Gromit   Members   

144
Like
Likes
Like

Posted 14 December 1999 - 05:42 PM

I believe that cin terminates the terminates the string when it reached a CR, SPACE..etc.

Try using printf();


#5 joeG   Members   

172
Like
Likes
Like

Posted 14 December 1999 - 06:39 PM

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


#6 acw83   Members   

174
Like
Likes
Like

Posted 15 December 1999 - 08:18 AM

Thanks for the help everyone!




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.