What is the Difference between "printf" and "sprintf"?
Answer Posted / prits
printf : Print formatted data to stdout (function)
sprintf:writes its results to a string instead of stdout
#include <stdio.h>
int main ()
{
char buffer [50];
int n, a=5, b=3;
n=sprintf (buffer, "%d plus %d is %d", a, b, a+b);
printf ("[%s] is a %d char long string\n",buffer,n);
return 0;
}
Is This Answer Correct ? | 31 Yes | 18 No |
Post New Answer View All Answers
Which ide is best for c++?
What is endianness?
What is a sequence in c++?
What is setbase c++?
What are formatting flags in ios class?
What is the return value of the insertion operator?
If I is an integer variable, which is faster ++i or i++?
Which one is better- macro or function?
What do you mean by global variables?
Explain the operation of overloading of an assignment operator.
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
What is class definition in c++ ?
Which programming language's unsatisfactory performance led to the discovery of c++?
Is c++ high level programming language?
what are the events occur in intr activated on interrupt vector table