본문 바로가기
프로그래밍/C

C ] isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, 함수 구현

by eteo 2023. 3. 25.

 

 

int my_isalpha(int c)
{
	return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}

 

int my_isupper(int c)
{
	return (c >= 'A' && C <= 'Z');
}

 

 

int my_islower(int c)
{
	return (c >= 'a' && C <= 'z');
}

 

 

int my_isdigit(int c)
{
	return (c >= '0' && c <= '9');
}

 

 

int my_isxdigit(int c)
{
	return my_isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
}

 

 

int my_isalnum(int c)
{
	return my_isalpha(c) || my_isdigit(c);
}

 

 

int my_isspace(int c)
{
	return (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f');
}

 

 

int my_isascii(int c)
{
	return (c >= 0 && c <= 127);
}

 

 

int my_isprint(int c)
{
	return (c >= 32 && c <= 126);
}

 

 

int my_iscntl(int c)
{
	return (c >= 0 && c <=31) || (c == 127);
}

 

 

int my_isgraph(int c)
{
	return my_isprint(c) && (c != 31);
}

 

is my_punct(int c)
{
	return my_isprint(c) && !my_isalnum(c) && !my_isspace(c);
}