函数原型:
int snprintf(char *restrict buf, size_t n, const char *restrict format, ...)
int sprintf(char *restrict buf, const char *restrict format,...)
snprintf()函数与sprintf()函数都可以向指针指向的位置写入数据,但snprintf可以指定写入数据的大小,因此可以有手段避免数据的溢出。
函数原型:
int snprintf(char *restrict buf, size_t n, const char *restrict format, ...)
int sprintf(char *restrict buf, const char *restrict format,...)
snprintf()函数与sprintf()函数都可以向指针指向的位置写入数据,但snprintf可以指定写入数据的大小,因此可以有手段避免数据的溢出。