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
How do I run a program in notepad ++?
What is the purpose of templates in c++?
Difference between a homogeneous and a heterogeneous container
What do the keywords volatile and mean mutable?
Why is c++ awesome?
What is the best c c++ compiler for windows?
How do I get good at c++ programming?
What is a node class in c++?
Describe friend function & its advantages.
What are structs in c++?
What does it mean to declare a member function as virtual?
What is a try block?
What do you mean by function and operator overloading in c++?
What is the difference between the compiler and the preprocessor?
How do you clear a map in c++?