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
What is runtime errors c++?
Explain binary search.
True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends
What is the benefit of c++?
What do c++ programmers do?
What is the use of bit fields in structure declaration?
How can you differentiate between inheritance and implementation in c++?
Why the usage of pointers in C++ is not recommended ?
State two differences between C and C++.
Explain the difference between abstract class and interface in c++?
What is copy constructor? Can we make copy constructor private in c++?
Explain terminate() and unexpected() function?
Why is c++ so fast?
Define macro.
What is type of 'this' pointer? Explain when it is get created?