char变量如何为整数和字符?

#include stdio.hint main(){char key;printf(Press a key on your keyboard:);key=getchar();

编程学习网为您整理以下代码实例,主要实现:char变量如何为整数和字符?,希望可以帮到各位朋友。

#include <stdio.h>
int main()
{
   char key;
   printf("Press a key on your keyboard:");
   key=getchar();
   printf("You pressed the '%c' key.\n",key);
   printf("Its ASCII value is %d.\n",key);
   return(0);
}
@H_301_2@

本文标题为:char变量如何为整数和字符?