The usage of sprintf function in C language

In the C language, we often use the sprintf function to convert integer, floating-point, and character variables into a string.


Print formatted output into a string
#include <stdio.h>

int sprintf( char* buf,
             const char* format,
             ... );

示例:

char  ch[20];

int  value = 20;

sprintf(ch,"%d\r\n",value);

 

Guess you like

Origin blog.csdn.net/modi000/article/details/112562812