Page 2 of 3
Re: Pause Function
Posted: Tue Jun 30, 2009 7:57 pm
by M_D_K
stupid retard 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!!
get() wouldn't works since no standard function is called that. fucking retard.
Re: Pause Function
Posted: Tue Jun 30, 2009 7:57 pm
by voidcyrax
o
Re: Pause Function
Posted: Tue Jun 30, 2009 7:59 pm
by voidcyrax
ok, so I made one mistake. it is getchar(). so fucking what? do i still have to write it for you too?
listen, i understand you are a really bad newb, so let me try to help you here:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
...
getchar()
...
}
NEWB!!!
Re: Pause Function
Posted: Tue Jun 30, 2009 8:01 pm
by M_D_K
still won't compile since it's incorrect code.
n00b.
Re: Pause Function
Posted: Tue Jun 30, 2009 8:05 pm
by voidcyrax
mdk is nothing but fail. has to protect other users, and has to butt in things that don't concern him. the code is correct. the only thing missing is the semicolon, which im not going to fix for scriptkiddy zodiac, he can do it himself.
Re: Pause Function
Posted: Tue Jun 30, 2009 8:06 pm
by zodiac976
voidcyrax wrote:ok, so I made one mistake. it is getchar(). so fucking what? do i still have to write it for you too?
listen, i understand you are a really bad newb, so let me try to help you here:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
...
getchar()
...
}
NEWB!!!
That doesn't work it only responds to 'ENTER'
and if you use getchar() like that it causes
more problems than cin.get().
I think you are using C includes...
these are for c++
#include <cstdio>
#include <cstdlib>
EDIT: you so funny :D.
Re: Pause Function
Posted: Tue Jun 30, 2009 8:15 pm
by zodiac976
Actually I think I found something that is working better
than cin.get();.
void pause()
{
cout << "Press ENTER to continue . . .";
cin.ignore(9999, '\n');
}
No more bugs but still you have to hit 'ENTER'.
Re: Pause Function
Posted: Tue Jun 30, 2009 9:04 pm
by avansc
zodiac976 wrote:Actually I think I found something that is working better
than cin.get();.
void pause()
{
cout << "Press ENTER to continue . . .";
cin.ignore(9999, '\n');
}
No more bugs but still you have to hit 'ENTER'.
yeah thats a brilliant way of doing it.
Re: Pause Function
Posted: Tue Jun 30, 2009 9:42 pm
by zodiac976
I found another way and tested it in my text RPG and
so far it works without relying on the 'ENTER' key but
I don't think it is a C++ standard.
You need #include <conio.h> to get it to work.
I thought conio was for some other compiler...
EDIT: I use visual C++ 2008 Express Edition.
void pause()
{
cout << "Press any key to continue . . .";
_getch();
}
I tried using just getch() and the compiler said to use
_getch(). So far I haven't gotten any errors with it.
Re: Pause Function
Posted: Wed Jul 01, 2009 12:05 am
by eatcomics
voidcyrax wrote:You all suck
You're dumb go away
01001110
00110000
00110000
00111000
!!!!!!!!!!!!
Re: Pause Function
Posted: Wed Jul 01, 2009 12:19 am
by dejai
system("PAUSE"); in general is a bad idea. If you had googled it you would have found this article:
http://www.gidnetwork.com/b-61.html
Let me quote it:
*
t's a very expensive and resource heavy function call. It's like using a bulldozer to open your front door. It works, but the key is cleaner, easier, cheaper. What system() does is:
1.
suspend your program
2.
call the operating system
3.
open an operating system shell (relaunches the O/S in a sub-process)
4.
the O/S must now find the PAUSE command
5.
allocate the memory to execute the command
6.
execute the command and wait for a keystroke
7.
deallocate the memory
8.
exit the OS
9.
resume your program
There are much cleaner ways included in the language itself that make all this unnessesary.
*
You must include a header you probably don't need: stdlib.h or cstdlib
It's a bad habit you'll have to break eventually anyway.
Instead, use the functions that are defined natively in C/C++ already. So what is it you're trying to do? Wait for a key to be pressed? Fine -- that's called input. So in C, use getchar() instead. In C++, how about cin.get()? All you have to do is press RETURN and your program continues.
Re: Pause Function
Posted: Wed Jul 01, 2009 12:41 am
by zodiac976
dejai wrote:system("PAUSE"); in general is a bad idea. If you had googled it you would have found this article:
http://www.gidnetwork.com/b-61.html
Let me quote it:
*
t's a very expensive and resource heavy function call. It's like using a bulldozer to open your front door. It works, but the key is cleaner, easier, cheaper. What system() does is:
1.
suspend your program
2.
call the operating system
3.
open an operating system shell (relaunches the O/S in a sub-process)
4.
the O/S must now find the PAUSE command
5.
allocate the memory to execute the command
6.
execute the command and wait for a keystroke
7.
deallocate the memory
8.
exit the OS
9.
resume your program
There are much cleaner ways included in the language itself that make all this unnessesary.
*
You must include a header you probably don't need: stdlib.h or cstdlib
It's a bad habit you'll have to break eventually anyway.
Instead, use the functions that are defined natively in C/C++ already. So what is it you're trying to do? Wait for a key to be pressed? Fine -- that's called input. So in C, use getchar() instead. In C++, how about cin.get()? All you have to do is press RETURN and your program continues.
I knew and know that :/.
I found that in google a long time ago and in my
previous posts I said it was bad and I wanted
to move away from it....if you are replying to me
that is...
.
Re: Pause Function
Posted: Wed Jul 01, 2009 6:28 am
by Netwatcher
Is think you have to check wether you get an input from the keyboard, and that's it...
so just check if WM_KEYDOWN is true...
for more info
http://msdn.microsoft.com/en-us/library/ms912654.aspx (on WM_KEYDOWN)
Re: Pause Function
Posted: Wed Jul 01, 2009 11:10 am
by eatcomics
Re: Pause Function
Posted: Wed Jul 01, 2009 5:27 pm
by zodiac976
Who is this guy he sounds like an immature kid not getting
his way.