当前位置:网站首页>How to use sprintf function
How to use sprintf function
2022-07-28 22:41:00 【The poorest are beggars and immortals will always come out】
One 、 Introduce
1、 This function is contained in stdio.h In the header file , Therefore need #include <stdio.h>.
2、sprintf In peace, we often use printf The functions are very similar .sprintf Function to print to a string ( Note that the length of the string should be enough to accommodate the printed content , Otherwise, there will be a memory overflow ), and printf Function prints out to the screen .sprintf Functions are often used to encapsulate specific strings like arrays .
3、sprintf Format of function :
int sprintf( char *buffer, const char *format [, argument,…] );
Be careful sprintf The first parameter of the function is a character pointer , Therefore, when declaring , The array declaration is called character type ; If declared as another type , Attention switching .
Two 、 example sentence
example :
1、
char str[20]; // Directly declared as a string array
sprintf(str,"%d-%2d-%2d",year,month,day);2、
unsigned char str[20]; // It is not directly declared as a string array , To convert
sprintf((char*)str,"%d-%2d-%2d",year,month,day);边栏推荐
- PaddleNLP基于ERNIR3.0文本分类:WOS数据集为例(层次分类)
- Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
- 20-09-27 the project is migrated to Alibaba toss record (the network card order makes the service unable to connect to DB through haproxy)
- 使用PCL批量显示PCD点云数据流
- 6K6w5LiA5qyh5pS75Ye75YiG5p6Q
- CMD common commands
- The function of wechat applet to cut pictures
- 771. The longest consecutive character in a string
- 静态成员static详解
- 771. 字符串中最长的连续出现的字符
猜你喜欢

6K6w5LiA5qyh5pS75Ye75YiG5p6Q

Netease Yunxin 2022q2 product supply station, come and get your product supply plan!

(翻译)图技术简明历史
How do we do full link grayscale on the database?

CMD common commands
Integrating database Ecology: using eventbridge to build CDC applications

Ultra detailed visual studio 2019 running littlevgl (lvgl) simulator

How to install WiFi correctly
![[CVPR 2021] cylinder3d: cylindrical asymmetric 3D convolution network for LIDAR point cloud segmentation](/img/3d/3def78ec88419712e14cf437e21447.png)
[CVPR 2021] cylinder3d: cylindrical asymmetric 3D convolution network for LIDAR point cloud segmentation

What are the main functions and uses of LCR tester
随机推荐
Summary of recent bugs
Concise history of graphic technology
Use PCL to batch convert point cloud.Bin files to.Pcd
Baidu map usage
Command line agent: proxychains configuration
For loops and functions
Sword finger offer II 066. sum of words (medium prefix tree design string)
79. Word search (medium string array matrix backtracking)
微信小程序里button点击的时候会边框有黑线
Changes in the history of oscilloscope development
imx6q gpio复用
Winserver operation and maintenance technology stack
PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
【转载】token令牌在登录场景使用
Netease Yunxin 2022q2 product supply station, come and get your product supply plan!
Idea generate class diagram plug-in UML (super detailed)
删除容器镜像报错解决image is referenced in multiple repositories
Use webworker to perform background tasks
JMeter installs third-party plug-ins plugins Manager
静态成员static详解