测试代码
#include <stdio.h>
//#define IS_LOWER(CH) (CH >= 'a' && CH <= 'z')
/* 定义一个和变量CH相同类型的临时变量_ch_,判断两者类型是否一致,不一致给出一个警告 */
#define IS_LOWER(CH) ({\
typeof(CH) _ch_ = CH;\
_ch_ >= 'a' && _ch_ <= 'z';\
})
int is_lower(char ch)
{
return (ch >= 'a' && ch <= 'z');
}
int main(int argc, const char *argv[])
{
char *str = "123ABCDabcdefg90YUI";
char *p = str;
int n = 0;
while ('\0' != *p) {
if (IS_LOWER(*p++))
n++;
}
printf("%d\n", n);
return 0;
}