How in C programming,we can assign a float value to a char value?

like if i calculated the any value ,whose result is ,say,17.346 then how can i display it in a function outtextxy() ???

Best Answer

Can't be done - there aren't enough bits in a char for a float, a float (usually) takes 32 bits. If your variable is an int you can do it with a cast, but that is extremely discouraged.

Actually, what you mean is not char but char *, address of an asciz string.

What you need to do is use something like sprintf() to make a character string of the value, and then use that.

You can't do a float to a char but you can to a string.

char buf[80];
float fred=2.345;

sprintf(buf, "%f", fred);

buf now = "2.345"

use "%x.nf" where x = size and n is no of decimal points for instance

sprintf(buf, "£.2f", fred);

will produce a monitory output.

30 Related Question Answers Found Date
looking for an online program that was created by an asian artist which turns line drawings into text pictures 2022-04-27 12:50
how do i stop people from saving my pictures on my piczo site? 2022-04-27 12:32
help with clips PLEASE!!? 2022-04-27 12:27
how to convert .jpg to .tif format? 2022-04-27 12:18
what is the way to export auto cad database to Microsoft access ? 2022-04-27 12:06
I have a program with a spaceship moving. I want to create a time interval for a boost method.? 2022-04-27 12:02
where can I find addresses for game developers? 2022-04-27 12:01
help me with spatial programming? 2022-04-27 11:56
Easy to use graphing software, for presentations, etc.? 2022-04-27 11:54
how much i can charge for a basic web page development? 2022-04-27 11:51
I want to make a online multiplayer game.? 2022-04-27 11:51
What could I add to my website to make it better? 2022-04-27 11:51
can anyone please help me find what font they used for their logo 'boccacinos' http://www.boccacinos.com/ 2022-04-27 11:48
How many tabs can be shown at once before they overwelm a user? 2022-04-27 11:48
How do i put sound/music on my web site? 2022-04-27 11:45
what is the easiest way? 2022-04-27 11:42
how do i get cut copy paste to work in my edit? 2022-04-27 11:41
How to design a logo for my forum? 2022-04-27 11:38
How can i print a frame in visual basic 6.0? 2022-04-27 11:34
Graphic Design.... what is it? 2022-04-27 11:27
Is there any online video tutorials to learn C# / .NET? 2022-04-27 11:26
Creating a forum and advertising? 2022-04-27 11:26
I am struggling-a logical qn? 2022-04-27 11:24
Myspace profile code help please? 2022-04-27 11:15
How to insert a php command in a HTML file ? 2022-04-27 11:14
Need some examples of Tic Tac Toe game in Java source code?? 2022-04-27 11:10
visual basic 2005 file stream question? 2022-04-27 11:06
slide show rpohect to >>>> jpg or png?????? 2022-04-27 10:57
Problem creating a simple Query with SQL Server 2005? 2022-04-27 10:56
I want information about a data art ...? 2022-04-27 10:47