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 an iterator class in c++?
You run a shell on unix system. How would you tell which shell are you running?
If all is successful, what should main return a) 0 b) 1 c) void
What are c++ variables?
What is a base class?
What are structures and unions?
Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?
What are guid?
What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required
Is eclipse good for c++?
What is implicit conversion/coercion in c++?
What is a storage class?
What is heap sort in c++?
What's the order in which the local objects are destructed?
What are the 2 main types of data structures?