apue的错误处理函数是不是有问题

C语言 码拜 9年前 (2016-04-19) 783次浏览
strcat(buf, “\n”);    // 这个地方是不是存在越界  ???

/*
 * Print a message and return to caller.
 * Caller specifies "errnoflag".
 */
static void
err_doit(int errnoflag, int error, const char *fmt, va_list ap)
{
	char	buf[MAXLINE];
	vsnprintf(buf, MAXLINE-1, fmt, ap);
	if (errnoflag)
		snprintf(buf+strlen(buf), MAXLINE-strlen(buf)-1, ": %s",
		  strerror(error));
	strcat(buf, "\n");    // 这个地方是不是存在越界  ???
	fflush(stdout);		/* in case stdout and stderr are the same */
	fputs(buf, stderr);
	fflush(NULL);		/* flushes all stdio output streams */
}
解决方案

35

5

你要看上面两句最多写入了多少字符啊,然后留了多少字符空间出来

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明apue的错误处理函数是不是有问题
喜欢 (0)
[1034331897@qq.com]
分享 (0)