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 do you mean by ‘void’ return type?
Where the memory to the static variables is allocated?
Can we get the value of ios format flags?
There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.
Is main a class in c++?
What are files in c++?
What is size_type?
Is c++ low level?
What is cout flush?
What are the basic data types used in c++?
find the two largest values among the 6 numbers using control structures : do-while,for,if else,nestedif- else ,while. one or two of them.
Do you know what are pure virtual functions?
Is dev c++ free?
What is c++ w3school?
Why do you use the namespace feature?