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 the advantages of using typedef in a program?
Explain object slicing in c++?
What is null c++?
What is the use of endl in c++?
Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).
What is the rule of three?
What are the syntactic rules to be avoid ambiguity in multiple inheritance?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
Is turbo c++ free?
What is the use of register keyword with the variables?
Are vectors faster than arrays?
What is a forward referencing and when should it be used?
What are the various arithmetic operators in c++?
How would you obtain segment and offset addresses from a far address of a memory location?
How is data hiding achieved in c++?