isdigit, iswdigit, _ismbcdigit
Nach oben zu ctype.h - Index
Header-Datei
ctype.h, mbstring.h
Kategorie
Klassifizierungsroutinen
Prototyp
int isdigit(int c);
int iswdigit(wint_t c);
int _ismbcdigit(unsigned int c);
Beschreibung
Prüft, ob eine Ziffer vorliegt.
isdigit ist ein Makro, das nach dem ASCII-Code codierte ganzzahlige Werte durch Nachschlagen in einer Tabelle klassifiziert. Das Makro wird durch die Kategorie LC_CTYPE des aktuellen Gebietsschemas beeinflusst. Beim Standardgebietsschema für C ist c eine Ziffer (0 bis 9)
Dieses Makro kann durch die Anweisung #undef als Funktion zur Verfügung gestellt werden.
Rückgabewert
isdigit gibt einen Wert ungleich 0 zurück, wenn c eine Ziffer ist.
_ismbcdigit gibt nur dann einen Wert ungleich 0 zurück, wenn das Argument c die Einzelbyte-Darstellung einer im ASCII-Code definierten Ziffer enthält.
Beispiel
#include <stdio.h>
#include <ctype.h>
int main(void)
{
char c = 'C';
if (isdigit(c))
printf("%c is a digit\n",c);
else
printf("%c is not a digit\n",c);
return 0;
}
Portabilität
POSIX | Win32 | ANSI C | ANSI C++ | |
---|---|---|---|---|
isdigit |
+ |
+ |
+ |
+ |
_ismbcdigit |
+ |
|||
iswdigit |
+ |
+ |
+ |