isalnum() 함수는 문자가 영숫자인지 확인하는 데 사용됩니다. 문자가 영숫자이면 문자 또는 숫자를 의미하는 경우 0이 아닌 값을 반환하고 그렇지 않으면 0을 반환합니다. "ctype.h" 헤더 파일에 선언되어 있습니다.
다음은 C 언어의 isalnum() 구문입니다.
int isalnum(int character);
여기,
캐릭터 − 확인할 문자입니다.
다음은 C 언어의 isalnum() 예제입니다.
예시
#include<stdio.h>
#include<ctype.h>
int main() {
char val1 = 's';
char val2 = '8';
char val3 = '$';
if(isalnum(val1))
printf("The character is alphanumeric\n");
else
printf("The character is not alphanumeric\n");
if(isalnum(val2))
printf("The character is alphanumeric\n");
else
printf("The character is not alphanumeric");
if(isalnum(val3))
printf("The character is alphanumeric\n");
else
printf("The character is not alphanumeric");
return 0;
} 출력
The character is alphanumeric The character is alphanumeric The character is not alphanumeric
위의 프로그램에서는 char형의 3가지 변수를 선언하고 그 값으로 초기화한다. 이러한 변수는 isalnum() 함수를 사용하여 이러한 값이 영숫자인지 여부를 확인합니다.
if(isalnum(val1))
printf("The character is alphanumeric\n");
else
printf("The character is not alphanumeric\n");