读书人

iswalpha函数的有关问题

发布时间: 2012-11-07 09:56:10 作者: rapoo

iswalpha函数的问题
wchar_t a=L'中';
我用iswalpha函数测试是否为字母,返回的结果不是0;
请问这个问题怎么解决呢?
谢谢大家。

[解决办法]

C/C++ code
#include <wctype.h>#include <stdio.h>int main(int argc, char* argv[]){    printf("%d\n", iswalpha(L'中'));    printf("%d\n", iswalpha(L'M'));    return 0;}//0//1024
[解决办法]
查MSDN是Windows程序员必须掌握的技能之一。

isalpha, iswalpha
int isalpha( int c );

int iswalpha( wint_t c );

Each of these routines returns true if c is a particular representation of an alphabetic character.

Routine Required Header Compatibility
isalpha <ctype.h> ANSI, Win 95, Win NT
iswalpha <ctype.h> or <wchar.h> ANSI, Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version


Return Value

isalpha returns a non-zero value if c is within the ranges A Z or a z. iswalpha returns a non-zero value only for wide characters for which iswupper or iswlower is true, that is, for any wide character that is one of an implementation-defined set for which none of iswcntrl, iswdigit, iswpunct, or iswspace is true. Each of these routines returns 0 if c does not satisfy the test condition.

The result of the test condition for the isalpha function depends on the LC_CTYPE category setting of the current locale; see setlocale for more information. For iswalpha, the result of the test condition is independent of locale.

Parameter

c

Integer to test

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_istalpha isalpha _ismbcalpha iswalpha


Character Classification Routines | Locale Routines | is, isw Function Overview

读书人网 >C++

热点推荐