语法:
null
int sprintf(char *str, const char *string,...);
返回:
If successful,it returns the total number of characters written excluding null-character appended in the string, in case of failure a negative number is returned .
sprintf代表“字符串打印”。它不在控制台上打印,而是将输出存储在sprintf中指定的字符缓冲区上。
C
// Example program to demonstrate sprintf() #include <stdio.h> int main() { char buffer[50]; int a = 10, b = 20, c; c = a + b; sprintf (buffer, "Sum of %d and %d is %d" , a, b, c); // The string "sum of 10 and 20 is 30" is stored // into buffer instead of printing on stdout printf ( "%s" , buffer); return 0; } |
输出
Sum of 10 and 20 is 30
如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END