ok this is my function at the moment ..
I still cannot get it to clear the buffer correctly . .
Code:
while (fgets(buff, MAX_LEN, fin) != NULL)
{
char custAction[MAX_LEN];
char custRef[MAX_LEN];
int i=0;
int x=0;
while((buff[i] != ' ') && (i <= MAX_LEN))
{ //read from buffer storing in custRef values up till
//a ' ' is found
custRef[i] = buff[i];
i++;
}
i++; //increment i past the space
while((buff[i] != ' ') && (i <=MAX_LEN) && (buff != NULL))
{ //read the rest of buffer till next space or EOF
custAction[x] = buff[i];
i++;
x++;
}
//printf("custAction is equal to - %s\n", custAction);
//for(j=0; j<MAX_LEN; j++)
//{
// buff[j] = ' '; //flush the strings. .
//}
memset(buff, 0, MAX_LEN); //reset buffer
printf("%s/n", buff);
time(&now);
fprintf(fout,"Customer %s: %s\nArrival time: %s\n", custRef, custAction, ctime(&now));
sleep(2);
}
i'm using the memset correctly .. so i figure it is in the wrong spot.. but i cannot find where it should be placed..
Matt