[Solved] Pause Function

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

[Solved] Pause Function

Post by zodiac976 »

I made my own clear screen function with the win32 API with a lot
of help but now I need a pause function that waits till any key is hit.

I made a temporary one like cin.get() but you have to hit enter and
if you enter some wierd letter or strings it causes some weird loops
and bugs...so I am wondering if there is a function that waits for
the user to hit any possible key then continues on with the program
or maybe a way to error check cin.get()?

Oh by the way I don't want to rely on system("pause")...too many
bad things about it.
Last edited by zodiac976 on Wed Jul 01, 2009 5:30 pm, edited 1 time in total.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Pause Function

Post by avansc »

you need to learn to google shit seriously.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

avansc wrote:you need to learn to google shit seriously.
I did google this for months and just stuck with system("pause") or
cin.get() which are very unreliable. I didn't ask for a google response
when I use google anyways, I asked for help on this topic. You remind
me of people that say read the manual, read the book, and then one
day they come across something they cannot figure out and then get
this response "use google" or "RTFM" from the same person or persons
;). I think you get the idea.
User avatar
Bakkon
Chaos Rift Junior
Chaos Rift Junior
Posts: 384
Joined: Wed May 20, 2009 2:38 pm
Programming Language of Choice: C++
Location: Indiana

Re: Pause Function

Post by Bakkon »

Can you just make a "Zodiac Learns C++" thread instead of making a new one every day?
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

Bakkon wrote:Can you just make a "Zodiac Learns C++" thread instead of making a new one every day?
Maybe good idea.
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: Pause Function

Post by programmerinprogress »

I actually made one, but felt like an ass when I saw the regards post, thus didn't post it :lol:
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

programmerinprogress wrote:I actually made one, but felt like an ass when I saw the regards post, thus didn't post it :lol:
I don't get that..there isn't anything bad in that post.
just thanking the people helping.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Pause Function

Post by avansc »

cin.get and system are C++ centric, not win32api

so... how about you google something like this... and see where you get.

http://www.google.com/search?hl=en&clie ... f&oq=&aqi=

you might not like my posts. but im just being frank and honest. if you cant deal with that im sorry but you should just toughen up.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

avansc wrote:cin.get and system are C++ centric, not win32api

so... how about you google something like this... and see where you get.

http://www.google.com/search?hl=en&clie ... f&oq=&aqi=

you might not like my posts. but im just being frank and honest. if you cant deal with that im sorry but you should just toughen up.
I am a C++ programmer not a windows programmer...
and the only code I have is for clearing the screen using the
win API which I have no clue what it means just that it clears
the screen under console. I rather have a C++ standard way of
clearing the screen without spamming newlines and not using
system("cls"). It only works with #include <windows.h>. That
is off topic anyways.

And is this windows programming:
http://www.google.com/search?hl=en&clie ... f&oq=&aqi=
If not set me straight.
voidcyrax

Re: Pause Function

Post by voidcyrax »

avan is right, if you cant even fucking google correctly, you should just give up... in life

zodiac, you are a dumbass, how can you not pause the app? If you're using a win32, then get win32 function, if you are using console apps, then use stream functions (cin, etc). if you're using directx, then get a directinput function,... for SDL use and sdl input function, etc. WHAT IS SO DIFFICULT!!??

it all depends on WHAT YOU ARE DOING!
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

voidcyrax wrote:avan is right, if you cant even fucking google correctly, you should just give up... in life

zodiac, you are a dumbass, how can you not pause the app? If you're using a win32, then get win32 function, if you are using console apps, then use stream functions (cin, etc). if you're using directx, then get a directinput function,... for SDL use and sdl input function, etc. WHAT IS SO DIFFICULT!!??

it all depends on WHAT YOU ARE DOING!
I can't pause the app? sure I can. I think you need to slow
down and read the above posts. I am looking for more
efficient way than system("pause") for example cause it
is just a huge security risk. I am not a windows programmer.

Why don't you give an example or if you are stubborn send
a link to lead me in the right direction instead of calling me
a quote you: "dumbass".
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Pause Function

Post by avansc »

what exactly do you wanna do. just pause the program? because you can make a FSM that enters a pause state under certain conditions.

if you wanna respond to each key stroke you need to do some smart things. i would suggest with your experience level that you just use a library like sdl glut .... etc that does keyboard handling for you.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

avansc wrote:what exactly do you wanna do. just pause the program? because you can make a FSM that enters a pause state under certain conditions.

if you wanna respond to each key stroke you need to do some smart things. i would suggest with your experience level that you just use a library like sdl glut .... etc that does keyboard handling for you.
Here is what I want to do and to be very specific I will
use one of my pause functions that work but it is not
very good.

EDIT: If this helps any I am doing all this code in console.

void pause()
{
cout << "Press ENTER to continue . . .";
cin.get();
}

The function will stop the program until they hit enter which I
rather have it be any key hit. If they type in characters and stuff
it just causes problems.

I am just trying to find a C++ standard way so I can stop using
everything related to system();

I did search this on google for months and they always have
Sleep(), system("pause") or almost the same thing as me.

The reason I brought this topic up was I thought since I can't
find anything on google or figure it out on my own yet I might
as well ask the forum.
voidcyrax

Re: Pause Function

Post by voidcyrax »

noooooooobb

noob noob noob noob!

all you have to do is replace cin.get, with get(). NOOB!

that way, once any character is inputted, the program continues on. NEEEEWWWWBBB!!
User avatar
zodiac976
Chaos Rift Regular
Chaos Rift Regular
Posts: 156
Joined: Thu Jun 18, 2009 10:03 am
Current Project: Booklet & Text RPG
Favorite Gaming Platforms: PC, PS3, PSP
Programming Language of Choice: C++
Location: AL
Contact:

Re: Pause Function

Post by zodiac976 »

voidcyrax wrote:noooooooobb

noob noob noob noob!

all you have to do is replace cin.get, with get(). NOOB!

that way, once any character is inputted, the program continues on. NEEEEWWWWBBB!!
replace cin.get() with get() this is what happens.
I am doing this for your sake.

error C3861: 'get': identifier not found

Now read your post again..I think you get it now..
I hope :lol:.
Post Reply