Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

2017


How can I open files mentioned on the command line, and parse option flags?

1015


Explain how many levels deep can include files be nested?

1025


What is || operator and how does it function in a program?

1041


How can variables be characterized?

2129


What is signed and unsigned?

1014


What is 1d array in c?

1029


What does %c do in c?

939


how to build a exercise findig min number of e heap with list imlemented?

2017


Why we not create function inside function.

2142


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?

2500


Why can arithmetic operations not be performed on void pointers?

982


program to convert a integer to string in c language'

2398


List some basic data types in c?

974


Why structure is used in c?

1113