Trying something basic and need help
Moderator: Coders of Rage
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Trying something basic and need help
getch() isn't portable either, I don't think.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Trying something basic and need help
Yeah it is... wait... lol... oops...
Alright just cin a line lol
char temp;
cin >> temp;
Alright just cin a line lol
char temp;
cin >> temp;
There's no place like ~/
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Trying something basic and need help
^
Not a good idea, the enter/newline is going to remain in the input buffer.
Not a good idea, the enter/newline is going to remain in the input buffer.
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Trying something basic and need help
Then we all give up...
Lets make a new forum about lawn chairs...
</sarcasm>
Then what do we use...?
Lets make a new forum about lawn chairs...
</sarcasm>
Then what do we use...?
There's no place like ~/
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Trying something basic and need help
Code: Select all
char temp[2];
cin >> temp;
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Trying something basic and need help
Amazing... So what IS in conio lol
There's no place like ~/
Re: Trying something basic and need help
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
Im thinking about just doing something like
Code: Select all
char f;
cin >> f;
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Trying something basic and need help
you could also simply do cin.clear() before cin.get(). Or you could use getchar(), which is in iostream.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Trying something basic and need help
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.
Code: Select all
while( 1 ){}
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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Trying something basic and need help
Aeolus, use
char temp[2]; cin >> temp;
to hold it open. As opposed to
char temp; cin >> temp;
char temp[2]; cin >> temp;
to hold it open. As opposed to
char temp; cin >> temp;
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: Trying something basic and need help
Thanks again Marauder
Hyde from That 70's Show wrote:Woman are like muffins... Once you have a muffin you will do anything to have another muffin... And they know that.
Re: Trying something basic and need help
I was wondering the same thing lol...LeonBlade wrote:Why array?
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
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Trying something basic and need help
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.
Last I heard newlines on windows from user were just \n, so, I dunno.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: Trying something basic and need help
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
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.