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


Please Help Members By Posting Answers For Below Questions

Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1760


How many bytes is a struct in c?

721


What is a static function in c?

619


When can a far pointer be used?

586


How can I call a function with an argument list built up at run time?

632






What is a built-in function in C?

788


What are the different types of C instructions?

669


Explain the binary height balanced tree?

719


What is the method to save data in stack data structure type?

600


What is string function c?

561


Why static is used in c?

618


What are register variables? What are the advantage of using register variables?

678


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

1697


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

1667


difference between Low, Middle, High Level languages in c ?

1630