C-introduction and usage of sprintf function

Introduction: The
sprintf function is used to convert numbers or texts into strings (char type, not u8 type).

How to use:
eg1:

char s1[14];
sprintf(s1,"%s","输入的次数:");  //将文字转为字符串。

eg2:

char s2[100];
sprintf(s2,"%d",number);          //将数字转为字符串

Essence version:
You can enter numbers and text at once.
eg:

int number = 100;
char s[50];

sprintf(s,"输入的次数:%d\n\r",number); //将文字、数字等转为字符串

Guess you like

Origin blog.csdn.net/Williamcsj/article/details/107303244