#include<stdio.h>
#include<ctype.h>
int check(int p)
{
int c = p;
//isdigit(char c)判断字符是否数字,当c为数字0到9时返回非零值,否则返回零;
if (isdigit(p))
//'0'的ASCII码为48
c = p - 48;
return c;
}
int main()
{
int c;
while ((c = getchar()) != EOF)
{
getchar();
c = check(c);
if (isalpha(c))
printf("该字符不是整数!\n");
else
printf("是:%d\n", c);
}
return 0;
}
字符串-----判断字符是否是整数
猜你喜欢
转载自blog.csdn.net/weixin_39916039/article/details/81536826
今日推荐
周排行