Demonstration of the use of structures in C. Inspiration to learn object-oriented programming for a more elegant solution.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 #include "patients.h" 00003 00004 //Pretend we have a pulse oximeter attached to A0 which provides the SpO2 00005 //as a fraction. 00006 AnalogIn pulse_oximeter(A0); 00007 00008 int main() 00009 { 00010 // Create an array of patient_record structures to form the patient database. 00011 struct patient_record all_patients[MAX_PATIENTS]; 00012 // Keep track of the number of patients. 00013 int enrollment=0; 00014 00015 //Add patient info. 00016 newPatient(&(all_patients[enrollment]),"George","Washington"); 00017 enrollment++; 00018 00019 newPatient(&(all_patients[enrollment]),"John","Adams"); 00020 enrollment++; 00021 00022 newPatient(&(all_patients[enrollment]),"Thomas","Jefferson"); 00023 enrollment++; 00024 00025 //Look up a patient--this one is not in our database. 00026 int X=lookup_patient_name(all_patients,"Abraham","Lincoln"); 00027 pc.printf("Abraham Lincoln is patient %d\n",X); 00028 00029 //Look up a patient. 00030 int Y=lookup_patient_name(all_patients,"Thomas","Jefferson"); 00031 pc.printf("Thomas Jefferson is patient %d\n",Y); 00032 00033 //Enter patient's vitals. 00034 recordBPinteractive(all_patients, pulse_oximeter); 00035 00036 while(1); 00037 00038 00039 }
Generated on Sun Jul 24 2022 01:36:53 by
1.7.2