Page 3 of 5
Re: Trying something basic and need help
Posted: Thu Jan 22, 2009 9:49 pm
by MarauderIIC
getch() isn't portable either, I don't think.
Re: Trying something basic and need help
Posted: Thu Jan 22, 2009 9:54 pm
by LeonBlade
Yeah it is... wait... lol... oops...
Alright just cin a line lol
char temp;
cin >> temp;
Re: Trying something basic and need help
Posted: Thu Jan 22, 2009 11:23 pm
by Falco Girgis
^
Not a good idea, the enter/newline is going to remain in the input buffer.
Re: Trying something basic and need help
Posted: Thu Jan 22, 2009 11:45 pm
by LeonBlade
Then we all give up...
Lets make a new forum about lawn chairs...
</sarcasm>
Then what do we use...?
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 12:07 am
by Falco Girgis
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 12:09 am
by LeonBlade
Amazing... So what IS in conio lol
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 2:16 am
by Aeolus
lol wow you guys confuse me. Saying all this technical shit. I looked in the chapter i read and theirs nothing about holding the program open to see the result.
Im thinking about just doing something like
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 5:38 am
by Ginto8
you could also simply do cin.clear() before cin.get(). Or you could use getchar(), which is in iostream.
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 12:23 pm
by dandymcgee
Just add:
Program will stay open as long as you need
NOTE: I just realized this actually "works".. For those of you that don't know this is a joke, it's a joke. DO NOT use this method.
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 2:56 pm
by MarauderIIC
Aeolus, use
char temp[2]; cin >> temp;
to hold it open. As opposed to
char temp; cin >> temp;
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 3:56 pm
by LeonBlade
Why array?
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 6:12 pm
by Aeolus
Thanks again Marauder
Re: Trying something basic and need help
Posted: Fri Jan 23, 2009 9:43 pm
by eatcomics
LeonBlade wrote:Why array?
I was wondering the same thing lol...
I have been using system("PAUSE");
and I have been meaning to change it but I'm too lazy to find a solution.... So an explanation would be nice lol
Re: Trying something basic and need help
Posted: Sat Jan 24, 2009 2:24 am
by MarauderIIC
Why array? Because Falco said in an earlier post that otherwise the newline would be stuck on the buffer *shrug*
Last I heard newlines on windows from user were just \n, so, I dunno.
Re: Trying something basic and need help
Posted: Sat Jan 24, 2009 5:04 am
by Ginto8
Instead of using an array, you could do this:
Code: Select all
cin.clear(); // clear the input buffer
cin.get() // wait for <break> to be pressed