codescracker


c

C sprintf()



« Previous Function Next Function »


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 Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test