i have my program doing what i want it to do untill it gets close to the end. the ouput that is transferred to the word document is not right. i have random charactes appearing before the "Date:". how can i fix this minor problem??
Thanks
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ofstream outputFile;
outputFile.open("C:\\Users\\Owner\\Desktop\\DoctorsOutPut.doc");
string Pname, CEmployer, AWUTDspecification, AMPM, RLhand,
AllergiesSpecification, HPI, SSN, TDate, DOB,DOI, IBP, MOFI,Complaints;
int age, n, y;
char AWUTD, Allergies;
n=0;
y=0;
AWUTD=0;
cout<<"Patients Name:"<<endl;
getline (cin, Pname);
cin.ignore(1000,'\n');
cout<<'\n';
cout<<"What is todays date?"<<endl;
getline (cin, TDate);
cout<<'\n';
cout<<"Age:"<<endl;
cin>>age;
cin.ignore(1000,'\n');
cout<<'\n';
cout<<"When is the patients birthday?"<<endl;
getline (cin, DOB);
cout<<'\n';
cout<<"Patients Social Security Number: "<<endl;
getline (cin, SSN);
cout<<'\n';
cout<<"What was the date of the injury?"<<endl;
getline (cin, DOI);
cout<<"Was appointment AM or PM"<<endl;
getline (cin, AMPM);
cout<<'\n';
cout<<"Employer:"<<endl;
getline (cin, CEmployer);
cout<<'\n';
cout<<"Right or Left Handed?"<<endl;
getline (cin, RLhand);
cout<<'\n';
cout<<"Does the patient have any allergies? Y/N"<<endl;
cin>>Allergies;
cin.ignore(1000,'\n');
cout<<'\n';
if(Allergies=='y'||Allergies=='Y')
{
cout<<"What is patient allergic to:"<<endl;
getline (cin, AllergiesSpecification);
cin.ignore(1000,'\n');
}
else if (Allergies=='n'||Allergies=='N')
{
cout<<endl;
}
cout<<"Patients HPI:"<<endl;
getline (cin, HPI);
cout<<'\n';
cin.ignore(1000,'\n');
cout<<"What are the injured body parts?"<<endl;
getline (cin, IBP);
cout<<"What is the mechanism of injury?"<<endl;
getline (cin, MOFI);
cout<<"Any complaints?"<<endl;
getline (cin, Complaints);
cin.ignore(1000, '\n');
cout<<"Any work up to date? Y/N"<<endl;
cin>>AWUTD;
if(AWUTD=='y'||AWUTD=='Y')
{
cout<<"Please Specify:"<<endl;
getline (cin, AWUTDspecification);
}
else if (AWUTD=='n'||AWUTD=='N')
{
cout<<endl;
}
cout<<'\n';
cout<<'\n';
cout<<'\n';
cout<<"Name: "<<Pname<<" "<<"Date: "<<TDate<<endl;
outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
cout<<"Age: "<<age<<" "<<"D.O.B: "<<DOB<<" "<<"SSN: "<<SSN<<endl;
outputFile<<"Age: "<<age<<" "<<outputFile<<"D.O.B:"<<DOB<<" "<<outputFile<<"SSN: "<<SSN<<endl;
cout<<"DOI: "<<DOI<<endl;
outputFile<<"DOI: "<<DOI<<endl;
cout<<"Appointment: "<<AMPM<<endl;
outputFile<<"Appointment: "<<AMPM<<endl;
cout<<"Employer: "<<CEmployer<<endl;
outputFile<<"Employer: "<<CEmployer<<endl;
cout<<"Right or Left handed: "<<RLhand<<"handed"<<endl;
outputFile<<"Right or Left handed: "<< RLhand<<"handed"<<endl;
cout<<"Allergies: "<<Allergies<<endl;
if
(Allergies=='y' || Allergies=='Y')
{
cout<<"Patient is allergic to:"<<AllergiesSpecification<<endl;
}
else if (Allergies =='n' || Allergies=='N')
{
cout<<endl;
}
cout<<"HPI: "<<HPI<<endl;
outputFile<<"HPI: "<<HPI<<endl;
cout<<"Injured body parts: "<<IBP<<endl;
outputFile<<"Injured body parts: "<<IBP<<endl;
cout<<"Mechanism of injury:"<<MOFI<<endl;
outputFile<<"Mechanism of injury:"<<MOFI<<endl;
cout<<"Complaints: "<<Complaints<<endl;
outputFile<<"Complaints: "<<Complaints<<endl;
cout<<"Any work up to date?"<<AWUTD<<endl;//if statement to show correct output
if
(AWUTD=='y' || AWUTD=='Y')
{
cout<<"Work up to date includes:"<<AWUTDspecification<<endl;
}
else if (AWUTD =='n' || AWUTD=='N')
{
cout<<endl;
}
outputFile.close();
};