problems reading binary file

hello
I'm trying to read the first 6 bytes of a file, but its giving me wired results and i cant seem to figure out what im doing wrong.

this is my code, that reads the file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct Block
{
	char fileSize[3];
	char initialDataBlockId[3];
};

int main(int c, char** a)
{
	
	ifstream file("C\\main_file_cache.idx0", ios::binary);

	Block block;
	
	file.get((char*)&block,sizeof(block));

	printf("File Size: %i\n", block.fileSize);
	printf("Initial Data Block ID: %i\n", block.initialDataBlockId);


	file.close();

	system("pause");
	return 0;
}


before i ran the code, i opened the file in a binary editor,
and it showed me this (hex):
1
2
3
4
00 00 00 00-00 00 05 af-4b 00 00 01-26 df cd 00
00 6f 03 3f-ed 00 03 61-05 08 35 00-04 8b 01 61
59 00 08 39-03 23 0a 00-05 6c 00 35-d0 00 06 fe
03 69 d8 00-07 19


there is a total of 54 bytes and as you can see the first 6 bytes are just 0.

so i expected to my program to output:
1
2
File Size: 0
Initial Data Block ID: 0


but instead it outputted this:
1
2
File Size: 10419128
Initial Data Block ID: 10419131


which makes no sense...
im guessing, maybe, there is something wrong with my code?

could someone help me please? :)

(it wouldn't let me post this under general c++, so i'm positing it here instead, i'm sorry if this result in a dupe post)
Hello stav,

On line 14 try file.read and see if that works.

Hope that helps,

Andy
Duplicate of http://www.cplusplus.com/forum/general/218903/

Please DON'T post multiple threads on the same topic. It wastes everyone's time, including your own.

C\\main_file_cache.idx0


should be:
 
C:\\main_file_cache.idx0 //what's the idx0 extension anyway? 
Topic archived. No new replies allowed.