xcdh-lzj 2021-11-18 17:56 采纳率: 100%
浏览 37
已结题

如果输入一个a,那么iCheck不是等于0吗,这样子的话输出就是错的了,为什么?

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main()
{
char cLetter;
int iInRange, iCheck, i, iLetter;
i = 1;
while (i)
{
printf("输入一个字母, 判断元音与辅音. 如果想退出,请输入“0”。\n");
scanf("%c", &cLetter);
getchar();
printf("----------------------------------------------------------------------\n");
iLetter = (int)cLetter;
iCheck = isalpha(iLetter);
if (iCheck)
{
iInRange = (cLetter == 'a') || (cLetter == 'e') || (cLetter == 'i') || (cLetter == 'o') || (cLetter == 'u') || (cLetter == 'A') || (cLetter == 'E') || (cLetter == 'I') || (cLetter == 'O') || (cLetter == 'U');
if (iInRange)
{
printf("字母 %c 是元音字母!\n", cLetter);
printf("----------------------------------------------------------------------\n");
continue;
}
else
{
printf("字母 %c 是辅音字母!\n", cLetter);
printf("----------------------------------------------------------------------\n");
continue;
}
}
else if (iCheck == 0)
{
if (iLetter != 48)
{
printf("Error input!\n");
printf("----------------------------------------------------------------------\n");
continue;
}
else if ((int)cLetter == 48)
{
printf("Bye bye~~~!\n");
printf("----------------------------------------------------------------------\n");
i = (int)cLetter - 48;
}
}
}
return 0;
}

  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-11-18 18:02
    关注

    iCheck = isalpha(iLetter);
    a是英文字母,返回的结果是1,为什么会等于0?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 11月26日
  • 已采纳回答 11月18日
  • 创建了问题 11月18日

悬赏问题

  • ¥15 像这种代码要怎么跑起来?
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件