I am reading from a file (fp) fourplets, that represent packets and if the generation time of the packet is less than the time running, then I am inserting it in to my list. The time increases by 20.0 every time slot. But I want to check all the packets from the file for the time between 0 and 20 and then between 20 and 40 etc. For example if a packet has generation time 13.9 and the time slot is 0-20, that means the packet will be inserted in the list, but another packet with generation time 24.5 will not be inserted in the list. I wrote the code below but it does not work like that.
double time=0.0;
while( fgets(buf,sizeof(buf),fp) != NULL ){
fscanf(fp, "%d %d %d %lf",&rollnumber, &src, &dest, &gentime);
printf("time: %.1f\n",time);
while (gentime<time && insertedpackets<=10){
insert(rollnumber,src,dest,gentime);
insertedpackets++;
display();
}time=time+20.0;