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 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


Please Help Members By Posting Answers For Below Questions

How do I run a program in notepad ++?

1103


What is the purpose of templates in c++?

1037


Difference between a homogeneous and a heterogeneous container

1142


What do the keywords volatile and mean mutable?

1051


Why is c++ awesome?

1029


What is the best c c++ compiler for windows?

1053


How do I get good at c++ programming?

1163


What is a node class in c++?

1067


Describe friend function & its advantages.

1133


What are structs in c++?

1029


What does it mean to declare a member function as virtual?

1077


What is a try block?

1070


What do you mean by function and operator overloading in c++?

1049


What is the difference between the compiler and the preprocessor?

1115


How do you clear a map in c++?

1122