VOOZH about

URL: https://www.geeksforgeeks.org/c/sprintf-in-c/

⇱ sprintf() in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

sprintf() in C

Last Updated : 10 Jan, 2025

Syntax: 

int sprintf(char *str, const char *string,...); 

Return: 

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 stands for “String print”. Instead of printing on console, it store output on char buffer which are specified in sprintf.


Output
Sum of 10 and 20 is 30


Time Complexity: O(n), where n is the number of elements being stored in buffer.
Auxiliary Space:  O(n), where n is the number of elements being stored in buffer.

Comment
Article Tags: