当前位置:网站首页>The difference between scnprintf and snprintf
The difference between scnprintf and snprintf
2022-06-22 09:10:00 【zuhan_ twenty million two hundred and ten thousand three hundre】
int snprintf(char *buf, size_t size, const char *fmt, ...)
int scnprintf(char *buf, size_t size, const char *fmt, ...)
Set the variable to a parameter (…) according to format Format as a string , Then copy it to str in .
(1) If the length of the formatted string < size, Then copy all of this string to str in , And add a string terminator to it (’\0’);
(2) If the length of the formatted string >= size, Only one of the (size-1) Characters copied to str in , And add a string terminator to it (’\0’), The return value is the length of the string to be written .
scnprintf() and snprintf() They don't cross the line , And will add a terminator on the last side ’\0’, The size of the returned value does not contain the last terminator , Will be truncated , Here's the difference :
scnprintf() Returns that has been written to buf The number of characters , and snprintf() Returns the length of the formatted character ( About to be written to buf The number of characters , Maybe it's better than size Be big ).
It is generally recommended to use scnprintf()
Reference link :https://blog.csdn.net/Namcodream521/article/details/85239473
https://blog.csdn.net/zhy025907/article/details/52494923
边栏推荐
- 嵌入式开发专业术语概念汇总
- Alibaba big fish SMS interface PHP version, simplified version Alibaba big fish SMS sending interface PHP instance
- 一学就会的tensorflow断点续训(原理+代码详解)
- User insight into the video industry in January 2022: active users began to pick up under the influence of holidays
- C语言刷题 | 判断某年是否只闰年(15)
- 【目标检测】|检测错误机制 Why Object Detectors Fail: Investigating the Influence of the Dataset
- Why can MySQL indexes improve query efficiency so much?
- 两个线程各执行100次i++,得到的可能值
- 【Tensorboard】所有雷区都踩,一文解决你所有问题
- Off line identification of least square method
猜你喜欢
![In the monorepo learning, execute NPM run build to report error[err\u require\esm] of ES module](/img/76/ec4776bcd452584290ef8bf5d0e06f.jpg)
In the monorepo learning, execute NPM run build to report error[err\u require\esm] of ES module

Threejs implementation of simple panoramic view demo

PHP login registration page

C# 进程如何使用非静态方法

Spark yard memory resource calculation and analysis (Reference) -- optimized configuration of executor cores, nums and memory

threejs实现简单全景看房demo

Medical information management system database mysql

Yolov5 export GPU inference model export

OpenCV每日函数 直方图相关(3)

让你轻松上手【uni-app】
随机推荐
Unicode字符/静态非静态的访问
Medical information management system database mysql
【node】快收下爬虫,我们不再为数据发愁
版本问题导致“无法定位程序输入点OPENSSL_sk_new_reserve于动态链接库C:\Users...\libssl-1_1-x64.dll”
IS_ERR()
Solidity from introduction to practice (III)
PHP output color image with specified height and width for web page background image
Record some Oracle operation commands
Solidity from introduction to practice (V)
My first go program
In the monorepo learning, execute NPM run build to report error[err\u require\esm] of ES module
逻辑回归和线性回归
Interview shock 59: can there be multiple auto increment columns in a table?
pip3 install xxx报错:Command 'lsb_release -a' returned non-zero exit status 1.
VMware安装Kali
It is hoped that more and more women will engage in scientific and technological work
【目标检测】|检测错误机制 Why Object Detectors Fail: Investigating the Influence of the Dataset
集合中的类--->你关注过那些是线程安全的吗?
np. Arange and np Linspace nuances (data overflow problem)
【Tensorboard】所有雷区都踩,一文解决你所有问题