Oh for crying out loud. Read your compiler manual and determine what your compiler uses for an int. It''s almost certainly 4 bytes.
You want absolute true portability? Than use sizeof () to do a runtime check and call the appropriate function.
Reading from a Binary File
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
My bad... The old noodle must not be getting enough nutrients
If a man is talking in the forest, and there is no woman there to hear him, is he still wrong?
First a little bit of background on ints
An int can be anything from 8 to 64 bits depending on the system. In DOS, an int took up 8 bits, in Windows 3.1 16 Bits, now in Windows 9x,NT they take 32 bits.
To make sure that you have the right type of integer, look into the documentation on the compilier like some other''s have said. If I was to choose, I would select a long, but then again, check into the documentation since, as I mentioned above, the size can change per system.
Kevin =)
An int can be anything from 8 to 64 bits depending on the system. In DOS, an int took up 8 bits, in Windows 3.1 16 Bits, now in Windows 9x,NT they take 32 bits.
To make sure that you have the right type of integer, look into the documentation on the compilier like some other''s have said. If I was to choose, I would select a long, but then again, check into the documentation since, as I mentioned above, the size can change per system.
Kevin =)
-----------------------------kevin@mayday-anime.comhttp://www.mayday-anime.com
I would suggest you make a struct called bsp_header or what ever you wish. Here is how i do it and it works. Too bad the rest of my q2 viewer dont yet.
struct BSPHeader
{
char magic[4]; // IBSP
unsigned long int version; // Version of the BSP format (38)
BSPLump lump[19]; // Lumps
};
Then read it in like so.
fread(&myHeader, sizeof(BSPHeader), 1, file);
Where myHeader is a variable of BSPHeader. And file, well you know what that is. Then just check each subscript in the magic array to see if it is IBSP.
-Snyper
Edited by - Snyper on November 10, 2000 12:15:40 PM
Edited by - Snyper on November 10, 2000 12:19:56 PM
struct BSPHeader
{
char magic[4]; // IBSP
unsigned long int version; // Version of the BSP format (38)
BSPLump lump[19]; // Lumps
};
Then read it in like so.
fread(&myHeader, sizeof(BSPHeader), 1, file);
Where myHeader is a variable of BSPHeader. And file, well you know what that is. Then just check each subscript in the magic array to see if it is IBSP.
-Snyper
Edited by - Snyper on November 10, 2000 12:15:40 PM
Edited by - Snyper on November 10, 2000 12:19:56 PM
=============================Where's the 'any' key?=============================
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement