I am going to read a file and output all the elements. But when I am reading and outputting, It will just display the first element only and won't go through the second. Thank you guys first. Appreciate
int main(){
ifstream patientRead ;
patientRead.open("Patient_List.txt") ;
string name ,ID, address , docName , diagnosis , patientStatus , consultationDate ;
int age ;
if(patientRead.is_open()){
while(getline(patientRead ,name), patientRead >> ID >> age >> address >> docName >> diagnosis >> patientStatus >> consultationDate){
int count = 0;
count ++ ;
cout<< "Patient " << count << endl ;
cout<< "Name : " << name << endl ;
cout<< "ID : " << ID << endl ;
cout<< "Address : " << address << endl ;
cout<< "Doctor Name : " << docName << endl ;
cout<< "Diagnosis : " << diagnosis << endl ;
cout<< "Patient Status : " << patientStatus << endl ;
cout<< "Consultation Date : " << consultationDate << endl << endl;
}
}else{
cout << "Unable to open" ;
}
patientRead.close();
}
This is the pattern of the file(File Name: "Patient_List.txt"):
ZI ZI ZI
UMMY123456 19 NO1234 DrDomo FEVER OUTPATIENT 15/5/2021
LIM LIM LIM
UMMY987654 25 NO0987 DrDomo FEVER OUTPATIENT 15/5/2021