3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by jephthah
-1

First of all, your file should be written in binary which contains nothing but the objects of your c structure.

Here's a breakdown of what you should do:
1. Open the file in binary format and read to the end of the file. Make sure the size is correct (correct size should be a multiple of your c structure's size)
2. If the structure is correct, allocate memory to the pointer using malloc()
3. use fread() to read the whole chunk to the pointer

You're now ready to access your c structure from the pointer.

0

First of all, your file should be written in binary which contains nothing but the objects of your c structure.

LOL WUT?

come on man, if you're going help, at least make sense. I think i know what you mean, but i doubt any beginning C coder does.


Here's a breakdown of what you should do ... <snip>

this makes way too many assumptions.

ramakrishna, you need to tell us more information about what your structure and your file looks like and what kind of assumptions can be made about the size, order, and relative placement of elements.

In other words, what are you trying to do, exactly?

Edited by jephthah: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.