网上有关“c语言中中getch()函数为何不起作用?”话题很是火热,小编也是针对c语言中中getch()函数为何不起作用?寻找了一些与之相关的一些信息进行分析,如果能碰巧解决你现在面临的问题,希望能够帮助到您。
你共犯了三点原则性的错误!
第一点:
你既然用了getch()函数,在前面就应有头文件#include<conio.h>。因为:
conio是Console Input/Output(控制台输入输出)的简写,其中定义了通过控制台进行数据输入和数据输出的函数,主要是一些用户通过按键盘产生的对应操作,比如getch()函数等等。
包含的函数
cgets(char *);
cprintf(const char *, ...);
cputs(const char *);
cscanf(const char *, ...);
inp(unsigned short);
inpw(unsigned short);
getch(void);
getche(void);
kbhit(void);
outp(unsigned short, int);
outpw(unsigned short, unsigned short);
putch(int);
ungetch(int);
void _Cdecl clreol (void);
void _Cdecl clrscr (void);
void _Cdecl delline (void);
int _Cdecl gettext (int left, int top, int right, int bottom,
void *destin);
void _Cdecl gettextinfo (struct text_info *r);
void _Cdecl gotoxy (int x, int y);
void _Cdecl highvideo (void);
void _Cdecl insline (void);
void _Cdecl lowvideo (void);
int _Cdecl movetext (int left, int top, int right, int bottom,
int destleft, int desttop);
void _Cdecl normvideo (void);
int _Cdecl puttext (int left, int top, int right, int bottom,
void *source);
void _Cdecl textattr (int newattr);
void _Cdecl textbackground (int newcolor);
void _Cdecl textcolor (int newcolor);
void _Cdecl textmode (int newmode);
int _Cdecl wherex (void);
int _Cdecl wherey (void);
void _Cdecl window (int left, int top, int right, int bottom);
har *_Cdecl cgets (char *str);
int _Cdecl cprintf (const char *format, ...);
int _Cdecl cputs (const char *str);
int _Cdecl cscanf (const char *format, ...);
int _Cdecl getch (void);
int _Cdecl getche (void);
char *_Cdecl getpass (const char *prompt);
int _Cdecl kbhit (void);
int _Cdecl putch (int c);
int _Cdecl ungetch (int ch);
第二点:
你没弄清getch()的用法。谨记如下:
getch直接从键盘获取键值,不等待用户按回车,只要用户按一个键,getch就立刻返回,getch返回值是用户输入的ASCII码,出错返回-1.输入的字符不会回显在屏幕上.getch函数常用于程序调试中,在调试时,在关键位置显示有关的结果以待查看,然后用getch函数暂停程序运行,当按任意键后程序继续运行.
第三点:
本次提问没有说清楚你编的程序想要干什么?
关于“c语言中中getch()函数为何不起作用?”这个话题的介绍,今天小编就给大家分享完了,如果对你有所帮助请保持对本站的关注!
本文来自作者[傲薇]投稿,不代表盛龙号立场,如若转载,请注明出处:https://wap.snlon.net/sn/51585.html
评论列表(3条)
我是盛龙号的签约作者“傲薇”
本文概览:网上有关“c语言中中getch()函数为何不起作用?”话题很是火热,小编也是针对c语言中中getch()函数为何不起作用?寻找了一些与之相关的一些信息进行分析,如果能碰巧解决你...
文章不错《c语言中中getch()函数为何不起作用?》内容很有帮助