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
Can a list of string be stored within a two dimensional array?
What is a responder chain?
I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?
What's the order in which the local objects are destructed?
Explain one-definition rule (odr).
Difference between strdup and strcpy?
What is data types c++?
What are associate containers?
What is lambda in c++?
Explain function overloading and operator overloading.
How does com provide language transparency?
What is the basic of c++?
Why are pointers used?
What is scope in c++ with example?
What is c++ & why it is used?