Tuesday 24 July 2012

sprintf() function | implementation | how to

c program sprintf() function:

This function is same as printf() function but it sends the formatted output to a string instead of screen.
So we can convert a variable data type into string using sprintf() function.

/*Program to illustrate the use of sprintf() function*/

#include
int main()
{
//declare two strings
char s1[20];
char s2[20];

//declare int and float variables

int n=7890;

float f=2345.67;
//convert the variables into string
sprintf(s1,"%d",n);
sprintf(s2,"%0.1f",f);
//print the converted strings
printf("s1=%s,s2=%s\n",s1,s2);

}
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: