原型
根据参数format字符串来转换并格式化数据,然后将结果复制到参数str所指的字符串数组,直到出现字符串结束(’\0’)为止。
1 2 3 4 5 6 7 8 9
|
int sprintf(char *str, const char * format,.........);
|
使用参考
1 2 3 4 5 6 7 8 9 10
| #include<stdio.h>
main() { char *str= "ABCEDFG!"; char buf[80]; sprintf(buf, "abcdefg%s\n", str);
printf("%s", buf); }
|