当前位置:网站首页>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);边栏推荐
- STM32CUBEIDE(10)----ADC在DMA模式下扫描多个通道
- Using nodejs to operate MySQL
- MySQL built-in functions
- 删除容器镜像报错解决image is referenced in multiple repositories
- Sword finger offer II 067. maximum XOR (medium prefix tree bit operation array)
- [reprint] the token token is used in the login scenario
- Summary of common error types in JS
- Winserver operation and maintenance technology stack
- PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
- Quadruped robot | gem (elevation map) + fast_ Deployment records of Leo (odometry) environment
猜你喜欢

Vscode ROS configuration GDB debugging error record

Sword finger offer II 054. Sum of all values greater than or equal to nodes (medium binary search tree DFS)

Sword finger offer II 053. Medium order successor in binary search tree (medium binary search tree DFS)

Ruiji takeout project - development of business development function Day2

Static details of static members

STM32 - systick timer (cubemx configures systick)

CMD common commands

基于Ernie-3.0 CAIL2019法研杯要素识别多标签分类任务

Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method

Paddlenlp text classification based on ernir3.0: take wos dataset as an example (hierarchical classification)
随机推荐
Sword finger offer II 055. Binary search tree iterator (medium binary search tree iterator)
The function of wechat applet to cut pictures
[Ruiji takeout project]day4 - dish management
容器化配置启动redis集群 单机6节点 3主3从
Sword finger offer II 052. flatten binary search tree (simple binary search tree DFS)
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
Changes in the history of oscilloscope development
Idea generate class diagram plug-in UML (super detailed)
MySQL command (add, delete, check and modify)
[get mobile information] - get mobile information through ADB command
CMD common commands
What does GPRS network mean
使用PCL批量将点云.bin文件转.pcd
32. Longest valid bracket (difficult stack string)
log4j漏洞 elk平台 处理方法 (logstah5.5.1)
STM32 -- program startup process
删除容器镜像报错解决image is referenced in multiple repositories
winform跳转第二个窗体案例
98. Verify binary search tree (medium binary search tree DFS)
Ngx+sql environment offline installation log (RPM installation)