Rajan Kumar

rajan

Founder & Programmer at HackersFriend Updated Jan. 16, 2020, 12:47 a.m. ⋅ 57 views

Convert a number to a string in C - best way


We can use sprintf() function to conver any number to string in C. Number can be any integer or float.

Here is an implementation of it.

#include<stdio.h> 
int main() 
{ 
	char final[100]; 

	float number = 98.12;
 
	sprintf(final, "%f", number);

	printf("\nString of given number is %s", final); 

	return 0;
} 

 

 



arrow_upward Upvote

comment Comment

arrow_downward downvote



Go back to feed

HackersFriend Updates





View more


Events


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details


Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details