what is the diff between the printf and sprintf functions??
and what is the syntax for this two functions ??
Answer Posted / santhi perumal
sprintf: This Writes formatted data to a character string in
memory instead of stdout
Syntax of sprintf is:
#include <stdio.h>
int sprintf (char *string, const char *format
[,item [,item]...]);
Here
String refers to the pointer to a buffer in memory where the
data is to be written. Format refers to pointer to a
character string defining the format. Each item is a
variable or expression specifying the data to write.
The value returned by sprintf is greater than or equal to
zero if the operation is successful or in other words the
number of characters written, not counting the terminating
null character is returned. And return a value less than
zero if an error occurred.
printf: Prints to stdout
Syntax for printf is:
printf format [argument]...
The only difference between sprintf() and printf() is that
sprintf() writes data into a character array, while printf()
writes data to stdout, the standard output device.
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
How can you find out how much memory is available?
how could explain about job profile
How many types of errors are there in c language? Explain
What is c system32 taskhostw exe?
What is the stack in c?
What are the advantages of union?
What is self-referential structure in c programming?
What is mean by data types in c?
What is main () in c language?
What is #include stdlib h?
Explain what are global variables and explain how do you declare them?
What is the use of #define preprocessor in c?
What are # preprocessor operator in c?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
What is the difference between break and continue?