大一新生,求帮助
我想要用scanf输入字符,但它为什么一直提示缺少int啊?
scanf_s()函数输入字符时,需加一个和参数有关的大小值,这么改:scanf_s("%c%c%c%c%c",&c1,1,&c2,1,&c3,1,&c4,1,&c5,1);
char+int,字符+整型???
下面的代码希望对你有帮助:
#include <stdio.h>
int main()
{
char c1;
int c2;
scanf("%c",&c1);
c2=c1+4;
printf("%d \n",c2);
return 0;
}
输入:a(a的ASCII码是97)
输出:101 (97+4=101)