Do You Coding?

[library] isprint ๊ตฌํ˜„ํ•˜๊ธฐ ๋ณธ๋ฌธ

CS & Engineering/C

[library] isprint ๊ตฌํ˜„ํ•˜๊ธฐ

๐Ÿ“Œ ๋งค๋‰ด์–ผ (Linux)

๋”๋ณด๊ธฐ

SYNOPSIS

       int isprint(int c);

: ํ•จ์ˆ˜ ํ”„๋กœํ† ํƒ€์ž…

 

DESCRIPTION

       isprint()
              checks for any printable character including space.

: ๋„์–ด์“ฐ๊ธฐ๋ฅผ ํฌํ•จํ•œ ์ธ์‡„ ๊ฐ€๋Šฅํ•œ ๋ฌธ์ž๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค

 

RETURN VALUE
       The  values  returned  are nonzero if the character c falls into the tested class, and zero if
       not.

: ๋ฐ˜ํ™˜๊ฐ’์€ ์กฐ๊ฑด์— ๋งŒ์กฑํ•˜์ง€ ์•Š์œผ๋ฉด 0์ด๊ณ , ๋งŒ์กฑํ•˜๋ฉด 0์ด ์•„๋‹Œ ๊ฐ’์ด๋‹ค

 

NOTES
       The standards require that the argument c for these functions is either EOF or a value that is
       representable in the type unsigned char.  If the argument c is of type char, it must  be  cast
       to unsigned char, as in the following example:

           char c;
           ...
           res = toupper((unsigned char) c);

       This  is  necessary  because  char  may be the equivalent of signed char, in which case a byte
       where the top bit is set would be sign extended when converting to int, yielding a value  that
       is outside the range of unsigned char.

       The details of what characters belong to which class depend on the locale.  For example, isupโ€
       per() will not recognize an A-umlaut (Ä) as an uppercase letter in the default C locale.

 

๐Ÿ“Œ ์ž‘์„ฑ ์ฝ”๋“œ

int	do_isprint(int d)
{
	if (d >= 32 && d <= 126)
		return (1);
	else
		return (0);
}

 

๐Ÿ“Œ ์ฝ”๋“œ ๋ฆฌ๋ทฐ

printable ํ•œ, ์ฆ‰ ์ถœ๋ ฅ๊ฐ€๋Šฅํ•œ ๋ฌธ์ž๋“ค์€ ASCII ํ‘œ ์ƒ์—์„œ 32 (๋„์–ด์“ฐ๊ธฐ) ๋ถ€ํ„ฐ 126 (~) ๊นŒ์ง€ ์ด๋‹ค.

๋”ฐ๋ผ์„œ ํ•ด๋‹น ๋ฒ”์œ„์— ์žˆ์œผ๋ฉด isprint ํ•จ์ˆ˜์— ์˜ํ•ด 1์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์•„๋‹ˆ๋ฉด 0์„ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ํ•œ๋‹ค.