read/write files

Hi all,

I have a problem with some read/write functions.
I have a .bin file which contains a lot of structures as follows:

struct alumno
{
char id[10]; 
char apellido1[32];
char apellido2[32];
char nombre[32];
float nota1p; 
float nota2p; 
float notamedia; 
char photofilename[20]; 

};

What I have to do is read the file, firstly one structure by one, and then all the file at once and change the value if notamedia is less than 3. I'm using read() and lseek(), but I'm very loss :(. Somebody can give me a hand in developing the code. I believe is not too big.
Thanks in advance for the help

you still have this problem? maybe i could help you.

hello ..
you can read the structures one by one. using the simple read command.
given by your information-> the size of your structure would be.
(assuming 32 bit architecture) . you can add the sizes of the tokens or you can do a simple sizeof() to find the value.
then read the values in a buffer one by one and extract the values one by one.
Reply..if you need more.
Regards :slight_smile:

Sure, show us your sample code. We could move further from there.