hi, i currently doing a program that can read from output file that i had created.Here is my problem : how do i read in randomly into struct
by the way i am using fread because i wanna read a binary file..and i don't know how to continue it..can i hav any tips..Thanks
Below are only part of the code..
Code:
typedef struct abc {

char a[10];
char b[20];
char c[30];

} Data;

etc...

Data *entry;
time_t t1;

/* let say i got a 100 data in the file and i wanna read only 10 randomly of it.. */

for (j=0; j<10 ; j++)
{
     
          srand48((long) tl); /* tl is a some time variable cos i need to calculate the timing too */
          fseek(infile, 0, SEEK_SET);
          random_number = lrand48()%1500000;

            if (fread(entry, sizeof(Data), 1, infile)) {
                
            /* i dunno what to do in here */
                
            /* issit correct if i do like this */
                fread(entry->a, sizeof(entry->a), 1, infile);
                .......

             }
       printf("%s,%s,%s\n",entry->a, entry->b, entry->c); 
       fseek(infile, 3 , SEEK_CUR);
    }