Using write to print floating point numbers.
- by Tom
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…