Mail Archives: djgpp/1999/03/16/16:20:36
Ya'qub (rick AT nct-active DOT com) wrote:
: Greetings,
: Sorry for posting this again but the first post didn't get any reply :(
: Can anyone please compile and run the following short program and tell me if
: they can get it to work.
: ----------------------
: #include <stdio.h>
: int main()
: {
: FILE* infid;
: FILE* outfid;
:
: short val;
:
: infid = fopen("output.dat","r");
: outfid = fopen("result","w");
:
: while (fscanf(infid,"%hX",&val) == 1)
: fprintf(outfid,"%.10f\n",(float)val/32768.0);
:
: fclose(infid);
: fclose(outfid);
:
: return 0;
: }
: --------------------------------------------------------
: The file output.dat contains numbers in hex, one per line e.g.
: 0x1234
: 0xF234
: 0x5678
:
: Whenever I run the program, the 'result' file is always empty. However, the
: same program runs fine when compiled and run from MSVC. Any ideas? Thanks.
: Ya'qub
It seems you have found a bug in MSVC.
Try "while (fscanf(infid," 0x%hX",&val) == 1)".
I havn't tried it but according to my C reference book %x and possibly
%X reads a base 16 number; not 0x followed by a base 16 number.
Shostakovich, String Quartet No. 15,
MartinS
- Raw text -