I have a sample review test I am working on for an exam tomorrow, and came across a question that I am unsure on how to implement.
It is asking me to Implement the function called Print_Records_that_contain_B, that prints all the fields of a patient.
I am given:
void Print_Records_that_contain_B(); //prints all the patient records that contain a "b" or "B" in the name field.
I assume it is something similar to my search function:
1 2 3 4 5 6 7 8 9 10 11 12
int patient_info::Search(string Patient_name){
int i;
for(i=0;i<count;i++){
if(patient_info[i].Patient_name == name){ //this somehow needs to find B/b
cout << i << patient_info[i].Patient_name
<<"\t"<<patient_info[i].age
<<"\t"<<patient_info[i].service_charge;
return i; //would have to increment count or i instead?
}
}
return (-1);
}
Please help. <3 I have not been taught this subject and would gladly appreciate seeing and understanding some code in which I can study for tomorrow.
The question doesn't make a lot of sense to me. So you want a function that loops on the array and finds all patients with 'b' or "B" anywhere in the name?
Boris Yeltsin, Linda Bowers, Rob Roy, Kareem Abdul Jabar would all be found and their records printed correct? Sounds like a weird requirement but it shouldn't be too hard to adapt the search function to do that. It could be done in many ways. Take a shot at it and let us know what you are confused about.