I have a text file 'patient_info.txt' like this:
100 Pranabesh 12/12/2014 15/12/2014 Dr.Ajit_Mukherjee,Dr.Pramotesh_Halder AC02 Tuberculosis
101 Sampad 01/03/2014 07/03/2014 Dr.Sarbani_Ghosh GEN304,Dengue
102 Sambit 22/11/2014 NA Dr.Vashkar_Ganguly GEN310 Liver_Malfunction
I need to take each line as input and compare the first field.The trouble is my code doesn,t read the lines after the first line and it goes into an infinite loop.
Code goes like this:::
while(1)
{
cout<<"Enter patient Id to display the details:";
cin>>id;
while(1)
{
r=fscanf(fp,"%d %s %s %s %s %s",&patient_id,&name,&admit_date,&release_date,&doc_consulted,&details);
while( r != EOF)
{
cout<<name<<endl;
if( patient_id == id)
{
cout<<name<<" "<<doc_consulted<<endl;
found=1;
break;
}
else
r=fscanf(fp,"%d %s %s %s %s %s",&patient_id,&name,&admit_date,&release_date,&doc_consulted,&details);
}
if( !found)
cout<<"\nInvalid Patient Id...Enter again....\n\n";
else
break;
}
if(found)
break;
}
I can't fix it.Please help....
Aucun commentaire:
Enregistrer un commentaire