_getch()(VS写getch()会报错)
用visual studio 2017写了关于_getch()的程序。用循环输入时每读一个字符后面都会加上尾零('\0'),怎样做才能在循环输入时自动加尾零,用Dev写getch()循环读入字符时不会有尾零。
程序代码:#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main(void)
{
char ch[10];
for (int i = 0; i < 10; i++) {
ch[i] = _getch();
printf("%c", ch[i]);
}
system("pause");
return 0;
}








