My program reads in data from a formatted data file and uses the data to fill in some structures with the correct data. There are several types of structures so I am trying to do this in a general fashion, rather than hundreds of a = b lines. If this is just not a good idea, please tell me and I can just abandon this approach. With each piece of data read in from the file I know how big the structure is supposed to be, and how big each field of data is. My Problem is that while a lot of the data seems to be filled out correctly in the structure, a lot of it seems like garbage or not what it is supposed to be. Constructive advice would be appreciated!

--Message Format
# Message Name
Message Number
Message Length
Field Size Min Max Default
Field Size Min Max Default

--Sample of Example of file the am reading data in from.
# Player Update
4 1 8 1
4 1 512 1
2 1 128 1
2 0 1 0
8 0 100000 0
8 -90.0 90.0 0
8 -180.0 180.0 0
4 -1000 60000 0

--Code From Project
//At this point we have already processed the message number and length
void CRangeCheck::ReadPlayerUpdate(std::ifstream* file, int nLen)
    char buffer[256];
    char seps[]   = "\t\n";
    char *nextTok;
    int currPos = 0;
    while(nLen - currPos > 0)

         int fieldSz = atoi(strtok_s( buffer, seps, &nextTok ));

        for(int i = 0; i < 3; i++)
            char *fieldBuff = strtok_s( NULL, seps, &nextTok );

            if(fieldSz == 8)
                double buff = atof(fieldBuff);
                memcpy(((unsigned char*)(&pduArray[i]->tPlayerData) + currPos), &buff, fieldSz) ;
                int buff = atoi(fieldBuff);
                memcpy(((unsigned char*)(&pduArray[i]->tPlayerData) + currPos), &buff, fieldSz) ;
        currPos += fieldSz;
--Structure Being Written Into
typedef struct
   int_4 id;
   int_2 type;
   int_2 team;
   float_8 time;
   float_8 lat;
   float_8 lon;
   float_4 alt;
   float_4 pos_n;
   float_4 pos_e;
   float_4 pos_d;
   float_4 vel_n;
   float_4 vel_e;
   float_4 vel_d;
   float_4 yaw;
   float_4 pitch;
   float_4 roll;
   int_2 plume_flag;
   int_2 detonate_flag;
   int_4 fired_wpn_id;
   int_4 pad2;
   int_4 pad3;
   int_2 emit_flag;
   int_2 firing_flag;     
   int_2 os_los_flag;
   int_2 damage;
   int_4 part1_type;
   float_4 part1_az;
   float_4 part1_el;
   int_4 part2_type;
   float_4 part2_az;
   float_4 part2_el;
   int_4 part3_type;
   float_4 part3_az;
   float_4 part3_el;
   int_2 weapon_status;
   int_2 pad1;
   T_Articulation Articulations[MAX_ARTICULATIONS];  // Index should be even to end on double word boundary
} T_player_data;