Author:dalerkd
0.2版本2015年3月25日 14:40:01
//判断当前控制台输入的ascii值,做进一步动作
#include "stdafx.h"
#include "stdlib.h"
#include "conio.h"
//本代码没有对“非数字”进行判断,这是为了程序的扩展。当然你可以通过对ascii的限制来完成判断的目的。
//本程序输入再多也不溢出哟
//是否可以通过外在的规则文件的输入使之能变通地解决一些问题?任Kitty—2015-3-11 20:20:27
//该函数总是可以获取当前输入的字符的ASCII,并通过switch-case对其进行判断.
int _tmain(int argc, _TCHAR* argv[])
{
system("title 你好.按“T”键退出");
while(1)
{
system("CLS");
printf ("输入要判断的数:");
char tmp[2];
int i=0;
while(1)
{
i=!(i);//一共有两个位置,通过这个语句使循环存储字符
tmp[i]=_getch();
putchar(tmp[i]);//回显输入,可关闭
switch (tmp[i])//想对什么响应就加入case吧.
{
/*case '\r':
{;
}*/
case 'T':
{
exit(0);
}
case 't':
{
exit(0);
}
default:
break;
}
}
}
}