- C Programming
- C Tutorial
- C Basic Syntax
- C Data Types
- C if...else Statement
- C switch Statement
- C for Loop
- C while Loop
- C do...while Loop
- C Jump Statements
- C Arrays
- C Strings
- C Pointers
- C Functions
- C Recursion
- C Variable Scope
- C Structures
- C Linked Lists
- C Stacks
- C Queues
- C Binary Trees
- C Header Files
- C File I/O
- C Programming Examples
- C Programming Examples
- Computer Programming
- C++ Tutorial
- C++ Examples
- C# Tutorial
- Python Tutorial
- Python Keywords
- Python Built-in Functions
- Python Examples
- Java Tutorial
- Java Examples
- PHP Tutorial
- Web Development
- HTML Tutorial
- CSS Tutorial
- JavaScript Tutorial
- SQL Tutorial
C sprintf()
The sprintf() function is same as the printf() function except that the output is put into the array pointed to by buf instead of being written to the stdout. The array pointed to by buf is null terminated.
sprintf() Syntax
#include<stdio.h> int sprintf(char *buf, const char *format, ...);
The return value is equal to the number of characters actually placed into the array.
The sprintf() provides no bound checking on the array pointed to by buf. It means that the array will be overrun if the output generated by sprintf() is greater than the array can hold.
sprintf() Example
After the following code fragments executes, str holds one 2 3 :
char str[80]; sprintf(str, "%s %d %c", "one", 2, '3');
« Previous Function C Examples »
Follow/Like Us on Facebook
Subscribe Us on YouTube