Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Saturday 1 June 2019

Purpose of sprintf() function


The sprintf() stands for "string print." 
The sprintf() function does not print the output on the console screen. It transfers the data to the buffer. It returns the total number of characters present in the string.

Syntax
int sprintf ( char * str, const char * format, ... );  

Let's see a simple example

 #include<stdio.h>  
int main()  
{  
 char a[20];  
 int n=sprintf(a,"javaabhigyan");  
 printf("value of n is %d",n);  
 return 0;
}  

Output:

value of n is 12

0 comments:

Post a Comment