delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/30/23:00:39

From: Dave Nugent <dave DOT nugent AT ns DOT sympatico DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Why does DJGPP's getw not read Borlands getw?
Date: Tue, 30 Dec 1997 13:18:49 -0800
Organization: Bell Solutions
Lines: 44
Message-ID: <34A96539.424E@ns.sympatico.ca>
Reply-To: dave DOT nugent AT ns DOT sympatico DOT ca
NNTP-Posting-Host: 142.177.13.49
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019