?? snprintf.c
字號:
/*
* Throughout the book I use snprintf() because it's safer than sprintf().
* But as of the time of this writing, not all systems provide this
* function. The function below should only be built on those systems
* that do not provide a real snprintf().
* The function below just acts like sprintf(); it is not safe, but it
* tries to detect overflow.
*/
#include "unp.h"
#include <stdarg.h> /* ANSI C header file */
int
snprintf(char *buf, size_t size, const char *fmt, ...)
{
int n;
va_list ap;
va_start(ap, fmt);
vsprintf(buf, fmt, ap); /* Sigh, some vsprintf's return ptr, not length */
n = strlen(buf);
va_end(ap);
if (n >= size)
err_quit("snprintf: '%s' overflowed array", fmt);
return(n);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -