![]() |
VOOZH | about |
In C, snprintf() function is a standard library function that is used to print the specified string till a specified length in the specified format. It is defined in the <stdio.h> header file.
In this article, we will learn about snprintf() function in C and how to use it in our program.
Below is an example to illustrate the working of snprintf() method:
Writing geeksforgeeks onto buffer with capacity 6 String written on buffer = geeks Value returned by snprintf() method = 14
The number of bytes printed to 'buffer' (excluding the null terminator) is 45 Joined string: The quick brown fox jumped over the lazy dog.