Thanks for the reply, I will try to clarify some points:
have 3 files.
First one a header with the struct and function definition:
Code:
typedef struct
{
char id[16];
char name32];
float nota1p;
float nota2p;
float notamedia;
char photofilename[20];
int photosize;
char photodata[16000];
}evaluation;
int review(int fd);
Second one with the main()
Code:
main()
{
int fd;
struct timeval t1, t2;
double secs;
int modify;
fd=open("datos.bin", O_RDWR, S_IRWXO);
printf("File Descriptor: %d\n", fd);
gettimeofday(&t1, NULL);
secs=t1.tv_usec/MICROX;
printf("time 1: %.6f \n",secs);
modify=review(fd);
gettimeofday(&t2, NULL);
secs=t2.tv_usec/MICROX;
printf("time 2: %.6f \n",secs);
In this one I'm trying to measure the time before and after the function, but is not working very good.
I also open the file
Third one with the function
Code:
#include </home/midori/arqui/header.h>
int review(int fd)
{
int nbytes;
void *buf;
nbytes=read(fd,buf,sizeof(evaluation));
}
The problem is that nbytes is different each time I run the program.
I want to read each structure in the file and then manipulate it, but I'm not sure how I can pass the struct to the function review() and how to use lseek to find a value of evaluation->notamedia < 3.
The main point is how can I manage the .bin file, I cannot even edit it to see how the data is structured there. So I cannot figure out how to use a function to find a specific data inside.
Maybe a pointer that which contais a 3.5 or bigger in binary format? lseek() function?
Thanks a lot for your help