memory mapping

Can someone point me in the right direction.
I want to open a file of a very specific size.
from there I want to assign pointers to various bytes in memory
I believe the best method of organizing them would be to create a data structure of pointers. The problem is I'm not very good with opening files. Most of my minimal experience reading from a file is through getline(). is there a way I can parse a file and directly access memory addresses of that file.
for instance, if I knew bytes 10 through 13 was a 32 bit number, it would be nice if I could cast a long pointer to 0x0A.

You can't cast a long pointer to an absolute offset, but you can create a pointer to the base address of the buffer + 10 bytes.

1234567891011

size_t eof;
// Open the file in binary (not text) mode.
ifstream datafile ("filename", ios::binary);
// position to eof // get the current position (eof)// Reposition to the start of the file char * buf = newchar[eof]; // Allocate a buffer for the file
datafile.read (buf, eof); // Read the file into the bufferlong * ptr = (long *)(buf + 10); // Point to a long starting at the 10th byte of the buffer
cout << "long at offset 10 = " << *ptr << endl;

Thanks for you help. That sounds like exactly what I wanted to do. I don't quite understand the last part but I am aware of longs being inturpreted as both 32 and 64 bit. If what you proposed at the bottom can remedy this, I'll look into it.

As for endianness issues, I generally don't deal with big endian architectures. When it comes to that I'll figure it out.

The function returns a pointer to a 32 bit value in your buffer. The function accepts the address of the buffer holding the file and the desired offset into the buffer (e.g. 10). It then performs the needed address arithmetic and returns you a pointer to the data you wanted. Using the function tends to be a lot clearer that doing the address arithmetic every time.