【发布时间】:2014-03-21 19:32:06
【问题描述】:
char ch;
ch=getch();
printf("%d",ch);
当我输入enter key 时显示的输出是
13
但是换行的ascii码是10,为什么会显示13呢?
以下代码在输入enter key 时无限运行
char *ch=malloc(100);
do
{
*ch=getch();
ch++;
}while(*(ch-1)!='\n');
【问题讨论】:
-
getch是非标准且不可移植的。请改用getchar。