More Adventures with Personal C
Saturday, 18th June 2016
In the past week I've been playing with the Personal C Compiler a lot more, particularly on the Hewlett Packard 100LX. It's surprising how quickly programs are compiled on the 7.91MHz processor. The compiler also comes with a source file later.c which compiles into a useful little utility which tests if one file is dated later than another. Its obvious use is to facilitate speedy compilation of larger projects. With it, I've been able to write a batch file that works as a rudimentary but effective makefile.
Bill C from http://www.desmet-c.com/ solved my previous problem with fseek(). It's not a bug, but the way in which the 16-bit compiler works. fseek() requires a long int argument for the number of bytes to skip, but a constant like 5 is a short int. So the line:
fseek (fp, 5, 0);
is feeding nonsense to fseek(). To make it work, the line needs to be:
fseek (fp, 5L, 0);
or when using a variable, as would usually be the case, the variable either needs to be of type long or needs to be cast as (long) when passed to fseek().