Mail Archives: djgpp/1997/12/30/23:00:39
Can someone explain to me why I have a file that was created in Borlands
Turbo C++ v3.0 that wrote a bunch of integers can't be read properly in
DJGPP?
example: Borland's
#include <stdio.h>
main()
{
FILE *out;
int one=2345; int two=19543; int three=27653;
out=fopen("tst","wb");
putw(one,out); putw(two,out); putw(three,out);
fclose(out);
}
// Now if I run the above, and write another small program using
the below I can read my integers back from a file.
#include <stdio.h>
main()
{
FILE *in;
int one=2345; int two=19543; int three=27653;
in=fopen("tst","rb");
one=getw(in); two=getw(in); three=getw(in);
fclose(out);
}
// This works ok fine in Borlands. But if I use the above reading
program written
in DJGPP's, I get like
one = 2323237823
two = -1
three = -1
Is there a difference in getw ?? I've checked the code over and can't
see
anything wrong? Is it because DJGPP has a different int size than
Borlands compiler?
If so, is there anything I can do to read my old files?
I have tried the getc and that seems to work fine.
Appreciate any suggestions!
Thanks!
- Raw text -