View Single Post
Old 04-18-2003, 02:44 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
hmm... if it's such a problem, then I would store every person on one line each, seperated with a <tab>, then when reading in from the file, you could do it like:
Code:
/*
    Some code here which I wont reveal
    maybe a main and some struct definition 
*/
   int people_counter = 0;
   while(!feof(file_pointer))
    {
      /*  
         yea yea, I know fscanf() is insecure when it comes to  
         buffer overflow, but it was the first thing that came to me
      */
      fscanf(file_pointer, "%s\t%s\t%s\t%d\t%d\t%s\t%d\n", 
               &x[people_counter].name, &x[people_counter].ssn, 
               &x[people_counter].city, &x[people_counter].age, 
               &x[people_counter].weight, &x[people_counter].eyes, 
               &x[people_counter].income);
      people_counter++;
    }
/* 
       here you can sum up the age and such, 
       using people_counter as the number to devide with
*/
bare in mind, none of the above has been tested, I wont say it's the correct thing to do, just a way to get your thoughts going, in what ways this might be solved.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote