c常用函数-sprintf

sprintf

sprinti函数的作用是把一个字符串格式化后输入到另一个字符串中,然后返回写入的·字符数量。

Sprinf在用法上和1.2.3节的prinf函数一致,区别是sprintf输出结果到指定的字符串中,而printf则把数据输出到标准的设备上。Sprint的语法结构如下: 
int sprintf ( char *string. const char *format_stringl, args] )

char test[30];
    int a = 2,b = 8;
    sprintf(test,"Add Test: a=%d,b=%d,a+b=%d.",a,b,a+b);
    lr_output_message(test);
    return 0;

输出:
Add Test: a=2,b=8,a+b=10.
是字符串结束标志
原文地址:https://www.cnblogs.com/lvchengda/p/12626350.html