" preSS任意键继续]在C函数 [英] "Press Any Key to Continue" function in C

查看:146
本文介绍了" preSS任意键继续]在C函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个空的功能,将工作为preSS任意键继续,在C程序设计?

我想要做的是:

 的printf(让战斗开始\\ n!);
的printf(preSS任意键继续\\ n);
//虚空功能这里
//然后我会打电话将启动游戏功能


解决方案

使用C标准库函数的getchar(),则getch()是Boreland酒店功能不是标准之一。

仅在Windows TURBO C.使用

 的printf(让战斗开始\\ n!);
的printf(preSS任意键继续\\ n);
的getchar();

您应该preSS返回键在这里。这样做的printf语句应该是preSS ENTER继续。

如果您preSS一个,然后再需要preSS ENTER键。结果
如果你preSS输入将正常继续。

这个原因,应该

 的printf(让战斗开始\\ n!);
的printf(preSS回车键继续\\ n);
的getchar();


如果您使用的是Windows,那么你可以使用残培()

 的printf(让战斗开始\\ n!);
的printf(preSS任意键继续\\ n);
残培();
//如果preSS任何字符,它会继续下去,
//但这不是一个标准的C函数。


 字符CH;
的printf(让战斗开始\\ n!);
的printf(preSS回车键继续\\ n);
//这里如果你还preSS任何其他键将等到pressing ENTER
scanf函数(%C,&安培; CH); //工作原理的getchar(),但在这里需要额外的变量。

How do I create a void function that will work as "Press Any Key to Continue" in C Programming?

What I want to do is:

printf("Let the Battle Begin!\n");
printf("Press Any Key to Continue\n");
//The Void Function Here
//Then I will call the function that will start the game

解决方案

Use C standard library function getchar() ,getch() is boreland function not standard one.

only used in windows TURBO C.

printf("Let the Battle Begin!\n");
printf("Press Any Key to Continue\n");  
getchar();    

you should press return key Here. for this the printf statement should be press ENTER to continue.

if you press a , then again you need to press ENTER.
if you press ENTER it will continue normally.

for this reason, it should be

printf("Let the Battle Begin!\n");
printf("Press ENTER key to Continue\n");  
getchar();    


If you are using windows then you can use getch()

printf("Let the Battle Begin!\n");
printf("Press Any Key to Continue\n");
getch();   
//if you press any character it will continue ,  
//but this is not a standard c function.


char ch;
printf("Let the Battle Begin!\n");
printf("Press ENTER key to Continue\n");    
//here also if you press any other key will wait till pressing ENTER
scanf("%c",&ch); //works as getchar() but here extra variable is required.      

这篇关于" preSS任意键继续]在C函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆