Mail Archives: djgpp/1999/06/25/11:55:26
This is a multi-part message in MIME format.
--------------040FEDFC5E1A3277B3E2B610
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I'm using the following code to make a hexdump of a binary file I
generated with a (turbo)pascal program. The strange thing is: I get an
end-of-file signal before the end of the file is reached. So, in a file
of 716 bytes, this method stops after having read 78 bytes, claiming it
has reached the end of the file. It seems to work well for files
generated with C++. And on the other hand, tpascal can deal with both
pascal- and C++ files. No particular character seems to be at location
78; with a hex-editor (which correctly shows all 716 bytes) I have 1A02
there (for bytes with decimal offset 78-79, or 79-78, with byte
inversion). Does anyone know what is going on here? Are there any other
tricky details involved in reading pascal-generated files with a
c-compiled program? Is there an online source about these?
I'm using egcs 1.2.
ifstream inpfile(cmdarglist[0].c_str(),ios::in||ios::binary);
unsigned short int x;
int n;
for(n=0;;n++) {
inpfile.read((char*)&x,sizeof(x));
if (inpfile.eof()) {
cout << endl << "End of file reached." << endl;
break;
}
if (inpfile.fail()) {
cerr << endl << "Error before end of file at byte " << n*sizeof(x)
<< endl;
break;
}
else cout << hex << x << " ";
}
clog << "Read " << n*sizeof(x) << " bytes." << endl;
--------------040FEDFC5E1A3277B3E2B610
Content-Type: text/x-vcard; charset=us-ascii;
name="peter.claessens.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Peter Claessens
Content-Disposition: attachment;
filename="peter.claessens.vcf"
begin:vcard
n:Claessens;Peter
tel;fax:+32 16 32 60 99
tel;home:+32 16 29 17 28
tel;work:+32 16 32 59 30
x-mozilla-html:FALSE
org:University of Leuven, Psychology department ;Laboratory for Experimental Psychology
adr:;;Tiensestraat 102;Leuven;;B-3000;BELGIUM
version:2.1
email;internet:peter DOT claessens AT psy DOT kuleuven DOT ac DOT be
fn:Peter Claessens
end:vcard
--------------040FEDFC5E1A3277B3E2B610--
- Raw text -