|
Until you sign up you can't do much. Yes, it's free.
|
|
|
|
|
|
|
 | / / / Viewing Topic
|  |
( Jx2 Anarchy )
Quality Control Engineer
|
im wiritng a program for my C++ class, here is the source http://www.miraclesalad.com/webtools/clip.php?clip=1491 its not completed, alot of stuff is left out, but, im trying to figure out why im getting the issue i am. (for the questions asked to continue, Y and N are answers atm) basically when i run the program and go into the fortune part of it (b) and i ask it a question, it outputs an answer, but instead of asking to continue, it goes over the answer, assumes you want to continue, and give an answer for a question you dont have in. then askes if you want to continue. obviusly this isnt right, and, when asked with anything that is only one word (no spaces) it seems to work correctly, anyone have an idea of what i have wrong here? Post edited at 1:55 pm on May 15, 2008 by Jx2 Anarchy
|
|
|
|
|
Just Waiting Here
Dairy Product Addict
Patron
Support Leader
|
I'm not too familiar with cin, so I looked around. http://www.macs.hw.ac.uk/~pjbk/pathways/cpp1/node185.html
When the input stream cin is used space characters, newline etc. are used as separators and terminators. Thus when inputting numeric data cin skips over any leading spaces and terminates reading a value when it finds a white-space character (space, tab, newline etc. ). This same system is used for the input of strings, hence a string to be input cannot start with leading spaces, also if it has a space character in the middle then input will be terminated on that space character. 
Looks like you may have to make a loop of some kind to pick it all up? I dunno... I also thought of what GdFtherOFCOWS said, and hopefully that will work. Otherwise, you may need a loop to pick up all the words in the string, and only consider it as one...? Lol, sorry I'm useless, it's been 4 years now since I've touched C++ and I never actually was taught the cin function... I'm interested in knowing how you got around the problem though, if you do figure it out :). But I think the problem all comes to the string and how cin works.
|
|
|
|
|
|
|
|
|
|
|
|
| Looking for something else?
|
|
|
|
|
|
 | / / / Viewing Topic |  |
|