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 you please explain the difference between static and dynamic binding of functions?
Why is c++ difficult?
How do you remove an element from a set in c++?
What is the difference between new() and malloc()?
Is oops and c++ same?
How do pointers work?
what is pre-processor in C++?
Can a program run without main in c++?
What's c++ used for?
How is data hiding achieved in c++?
What are structs in c++?
If dog is a friend of boy, and terrier derives from dog, is terrier a friend of boy?
Comment on assignment operator in c++.
What is c++ vb?
List different attributes in C++?