ctlstr.c

来自「unix高级编程源代码.<<unix高级编程>>」· C语言 代码 · 共 24 行

C
24
字号
#include	"calld.h"

/* Make a printable string of the character "c", which may be a
 * control character.  Works only with ASCII. */

char *
ctl_str(char c)
{
	static char	tempstr[6];		/* biggest is "\177" + null */

	c &= 255;
	if (c == 0)
		return("\\0");			/* really shouldn't see a null */
	else if (c < 040)
		sprintf(tempstr, "^%c", c + 'A' - 1);
	else if (c == 0177)
		return("DEL");
	else if (c > 0177)
		sprintf(tempstr, "\\%03o", c);
	else
		sprintf(tempstr, "%c", c);
	return(tempstr);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?