Hi,

Firstly apologies for the long post. I just want to try to make clear what i'm doing. i'm trying to read in values from two files then perform an operation on them later to ouput to another file. The files i'm reading from have data like this look like this :

Packet No.: 1
system_time.wHour: 18
system_time.wMinute: 31
system_time.wSecond: 21
system_time.wMilliseconds: 794
Bytes Sent: 21

The code i've developed so far deals with reading line by line, performing the required operations i.e. malloc and atoi. I'm not certain i'm attacking this the right way though the only error i get is with getline. Have tried to use fgets, fgetc and others. From reading through (many) posts i gather that i might read line using fgets and then parse it using sscanf. Is there a way i can use getline/fgetline? At the moment the error says that fgetline can't take 3 parameters. Should i make wholesale changes to code and try a different method? Any help would be appreciated, it's been driving me crazy.

Here's a sample of some of the code:


Code:
:
Code: cpp
int main()
{
  int bytes_read;
  int nbytes = 100;

  char *my_string1;
  char *my_string2;
  char *my_string3; //etc
........
.......
FILE * fp1;
int packetNo[1000];
 int time[1000];
int counter = 0;


fp1 = fopen("c:\\client.txt","r");

  my_string1 = (char *) malloc (nbytes + 1);
  my_string2 = (char *) malloc (nbytes + 1);
  my_string3 = (char *) malloc (nbytes + 1);

while (1) {
  bytes_read = getline (&my_string1, &nbytes, fp1);
  bytes_read = getline (&my_string2, &nbytes, fp1);
  bytes_read = getline (&my_string3, &nbytes, fp1);

packetNo[counter] = atoi(&my_string1[12]);

  time[counter] = atoi(&my_string3[12]) * 1000 + atoi(&my_string4[20]);
 
   counter++;
   
  }

fclose (fp1);

return 0;
}