问题描述
例如,我从输入中读取了一个字母
我需要判断它是字母还是数字
我正在做的是
char a;
...... //读一个
int true = false;
if(( (a> =''0'')&&(a< =''9''))| |((a> =''a'')&&(a< = ''z''))||((a> =''A'')
&&(a< =''Z'')))
true = 1;
有没有更简单的方法呢?
非常感谢!
isdigit(),isalpha()等。
-
Fred L. Kleinschmidt
波音助理技术研究员
技术架构师,软件重用项目
< hint>
尝试查看ctypes.h。
< / hint>
如果这不起作用,请尝试< ctype.h> 。
另外,请仔细阅读文档:这些函数接受
范围为[0,UCHAR_MAX]的值;如果你有一些简单的
或签名的字符,那么你必须在传递之前将它们转换为unsigned char
。
for instance, I read a char from the input
and I need to decide whether it is a letter or a number
What I am doing is
char a;
...... // read a
int true = false;
if(( (a >=''0'') && (a <=''9'')) | | ((a >=''a'') && (a <= ''z'')) ||((a >=''A'')
&& (a <= ''Z'')))
true = 1;
Is there any easier way for it?
Thanks a lot!
<hint>
Try looking in ctypes.h.
</hint>
--
Remove "your coat" to tontact me.
isdigit(), isalpha(), etc.
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
<hint>
Try looking in ctypes.h.
</hint>
If that doesn''t work, try <ctype.h> .
Also, read the documentation carefully: those functions accept
a value in the range [0, UCHAR_MAX]; if you have some plain
or signed chars then you have to cast them to unsigned char
before passing them.
这篇关于如何判断它是英文字母还是数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!