Press Enter To Continue

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

Post Reply
Master Jake
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 69
Joined: Sat Dec 12, 2009 8:43 pm
Programming Language of Choice: C/C++
Location: United States
Contact:

Press Enter To Continue

Post by Master Jake »

This function is very simple, but it can come in handy when making text-based rpg's. Unlike most "wait" functions, it does not display the characters entered and only accepts the enter (carriage return) to continue.

Required Libraries
stdio.h
conio.h

Code: Select all

void Wait()
{
	printf("\nPress <ENTER> To Continue . . .");

	char kbInput;
	
	do
		kbInput = _getch();

	while ((int) kbInput != 13);

	printf("\n");
}
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Press Enter To Continue

Post by Ginto8 »

Here's a simple, easier method in C/++ using stdio.h/cstdio that is not Windows-dependent (getch() and other conio.h functions are Windows-only). ;)

Code: Select all

void Wait()
{
    printf("\nPress <ENTER> To Continue . . .");
    while(getchar()!='\n');
    putchar('\n');
}
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.
Master Jake
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 69
Joined: Sat Dec 12, 2009 8:43 pm
Programming Language of Choice: C/C++
Location: United States
Contact:

Re: Press Enter To Continue

Post by Master Jake »

Nice =)

But the whole point of the above one was
it does not display the characters entered
As for Windows only, I'm still stuck in that world :(
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Press Enter To Continue

Post by eatcomics »

Jake go to the Linux side, it's awesome :D
Image
Post Reply