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
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
How can I open files mentioned on the command line, and parse option flags?
Explain how many levels deep can include files be nested?
What is || operator and how does it function in a program?
How can variables be characterized?
What is signed and unsigned?
What is 1d array in c?
What does %c do in c?
how to build a exercise findig min number of e heap with list imlemented?
Why we not create function inside function.
Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?
Why can arithmetic operations not be performed on void pointers?
program to convert a integer to string in c language'
List some basic data types in c?
Why structure is used in c?