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 are features of c++?
What are the advantages of using pointers in a program?
What is enum c++?
Is map ordered c++?
If dog is a friend of boy, is boy a friend of dog?
What do you mean by storage classes?
How can virtual functions in c++ be implemented?
Write a program to find the reverse Fibonacci series starting from N.
What is flush () in c++?
What are multiple inheritances (virtual inheritance)?
How do I get good at c++ programming?
What is the difference between an array and a list?
Is java the same as c++?
How to declare a function pointer?
What are enumerations?