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
Explain unexpected() function?
Explain function overloading and operator overloading.
What is virtual base class?
Explain dangling pointer.
What are the various storage classes in C++?
Describe delete operator?
What are single and multiple inheritances in c++?
Can a class be static in c++?
Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What are pointer-to-members? Explain.
What is the best it certification?
Is c++ used anymore?
Specify some guidelines that should be followed while overloading operators?
What is switch case in c++ syntax?
Why c++ is the best language?