I'm attempting to compile a program in C for the ZX Spectrum using Z88DK.
However, I'm facing an issue when trying to use printf
to print out the value of a float.
The code I'm trying to compile:
#include <stdio.h>
#include <math.h>
int main()
{
printf("Hello World\n");
printf("Testing float...\n");
double pi = 3.141;
printf("Pi is: %f\n", pi);
return 1;
}
and I'm compiling with:
zcc +zx -lm -create-app -startup=1 -clib=new main.c -o floatTest
The program compiles however nothing is printed on the screen where the value of the float should be. Here is a screenshot of the Fuse emulator output of the program above.
I've tried using float
and double
, adding different formatting options like %06.2f
, but nothing seems to work. I can't get anything to display on the screen.
I'm stuck on how to resolve this issue and any help would be appreciated!
float
-size argument, and it outputs nothing at all. Maybe your library works the same way. Maybe you even have the same option somewhere.double pi = 3.141; double m = pi/100.0; printf("Pi is: %f\n", pi);
or other such code.