Using write to print floating point numbers.
Posted
by Tom
on Stack Overflow
See other posts from Stack Overflow
or by Tom
Published on 2010-04-25T17:18:30Z
Indexed on
2010/04/25
17:23 UTC
Read the original article
Hit count: 202
Hi,
As an exercise to achieve something larger, i'm trying to use write to print a floating point number. I haven't done this in a while. I must be doing something wrong because I cant get it to work.
Here is my code
#include <unistd.h>
int main(){
float f = 4.5;
write(1,&f,sizeof float);
return 0;
}
However, when running it im getting
?@
Any thoughts?
Thanks in advance.
© Stack Overflow or respective owner