| | |
Help With Final Output
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 29
Reputation:
Solved Threads: 0
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
Thanks
C++ Syntax (Toggle Plain Text)
#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(); };
•
•
Join Date: Sep 2008
Posts: 90
Reputation:
Solved Threads: 12
c++ Syntax (Toggle Plain Text)
outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
c++ Syntax (Toggle Plain Text)
outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;
Last edited by unbeatable0; Apr 11th, 2009 at 1:51 pm.
Actually this:
is the same as this:
C++ Syntax (Toggle Plain Text)
outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;
is the same as this:
C++ Syntax (Toggle Plain Text)
outputFile<<"Name: "<<Pname<<"\t\t"<<"Date:"<<TDate<<endl;
Last edited by tux4life; Apr 11th, 2009 at 2:04 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
![]() |
Similar Threads
- Specific order of text output from XML using XSLT (XML, XSLT and XPATH)
- Predict and explain the output (C)
- trouble with long output string, plz help (PHP)
- Missing output from program (C++)
- How can i call my FileOutput method to output the array ?? really confused... (Java)
- Am not able to get a radio button selection to display in output (PHP)
- Need some final Touches Help (C++)
- Reverse Output (Stack) (C++)
Other Threads in the C++ Forum
- Previous Thread: long doubles
- Next Thread: bug fix
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector visualstudio win32 windows winsock word wordfrequency wxwidgets






