943,796 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 410
  • C++ RSS
Apr 11th, 2009
0

Help With Final Output

Expand Post »
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

C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9.  
  10. {
  11. ofstream outputFile;
  12. outputFile.open("C:\\Users\\Owner\\Desktop\\DoctorsOutPut.doc");
  13.  
  14. string Pname, CEmployer, AWUTDspecification, AMPM, RLhand,
  15. AllergiesSpecification, HPI, SSN, TDate, DOB,DOI, IBP, MOFI,Complaints;
  16. int age, n, y;
  17. char AWUTD, Allergies;
  18.  
  19. n=0;
  20. y=0;
  21. AWUTD=0;
  22.  
  23.  
  24. cout<<"Patients Name:"<<endl;
  25. getline (cin, Pname);
  26. cin.ignore(1000,'\n');
  27. cout<<'\n';
  28.  
  29. cout<<"What is todays date?"<<endl;
  30. getline (cin, TDate);
  31. cout<<'\n';
  32.  
  33.  
  34. cout<<"Age:"<<endl;
  35. cin>>age;
  36. cin.ignore(1000,'\n');
  37. cout<<'\n';
  38.  
  39.  
  40. cout<<"When is the patients birthday?"<<endl;
  41. getline (cin, DOB);
  42. cout<<'\n';
  43.  
  44.  
  45. cout<<"Patients Social Security Number: "<<endl;
  46. getline (cin, SSN);
  47. cout<<'\n';
  48.  
  49.  
  50.  
  51. cout<<"What was the date of the injury?"<<endl;
  52. getline (cin, DOI);
  53.  
  54.  
  55. cout<<"Was appointment AM or PM"<<endl;
  56. getline (cin, AMPM);
  57. cout<<'\n';
  58.  
  59.  
  60. cout<<"Employer:"<<endl;
  61. getline (cin, CEmployer);
  62. cout<<'\n';
  63.  
  64. cout<<"Right or Left Handed?"<<endl;
  65. getline (cin, RLhand);
  66. cout<<'\n';
  67.  
  68.  
  69. cout<<"Does the patient have any allergies? Y/N"<<endl;
  70. cin>>Allergies;
  71. cin.ignore(1000,'\n');
  72. cout<<'\n';
  73.  
  74. if(Allergies=='y'||Allergies=='Y')
  75. {
  76. cout<<"What is patient allergic to:"<<endl;
  77. getline (cin, AllergiesSpecification);
  78. cin.ignore(1000,'\n');
  79.  
  80. }
  81. else if (Allergies=='n'||Allergies=='N')
  82. {
  83. cout<<endl;
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. cout<<"Patients HPI:"<<endl;
  94. getline (cin, HPI);
  95. cout<<'\n';
  96. cin.ignore(1000,'\n');
  97.  
  98.  
  99. cout<<"What are the injured body parts?"<<endl;
  100. getline (cin, IBP);
  101.  
  102. cout<<"What is the mechanism of injury?"<<endl;
  103. getline (cin, MOFI);
  104.  
  105. cout<<"Any complaints?"<<endl;
  106. getline (cin, Complaints);
  107. cin.ignore(1000, '\n');
  108.  
  109.  
  110.  
  111. cout<<"Any work up to date? Y/N"<<endl;
  112. cin>>AWUTD;
  113.  
  114.  
  115. if(AWUTD=='y'||AWUTD=='Y')
  116. {
  117. cout<<"Please Specify:"<<endl;
  118. getline (cin, AWUTDspecification);
  119.  
  120. }
  121. else if (AWUTD=='n'||AWUTD=='N')
  122. {
  123. cout<<endl;
  124. }
  125.  
  126.  
  127.  
  128.  
  129. cout<<'\n';
  130. cout<<'\n';
  131. cout<<'\n';
  132.  
  133.  
  134.  
  135. cout<<"Name: "<<Pname<<" "<<"Date: "<<TDate<<endl;
  136. outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
  137.  
  138.  
  139.  
  140. cout<<"Age: "<<age<<" "<<"D.O.B: "<<DOB<<" "<<"SSN: "<<SSN<<endl;
  141. outputFile<<"Age: "<<age<<" "<<outputFile<<"D.O.B:"<<DOB<<" "<<outputFile<<"SSN: "<<SSN<<endl;
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. cout<<"DOI: "<<DOI<<endl;
  149. outputFile<<"DOI: "<<DOI<<endl;
  150.  
  151.  
  152. cout<<"Appointment: "<<AMPM<<endl;
  153. outputFile<<"Appointment: "<<AMPM<<endl;
  154.  
  155.  
  156. cout<<"Employer: "<<CEmployer<<endl;
  157. outputFile<<"Employer: "<<CEmployer<<endl;
  158.  
  159.  
  160.  
  161. cout<<"Right or Left handed: "<<RLhand<<"handed"<<endl;
  162. outputFile<<"Right or Left handed: "<< RLhand<<"handed"<<endl;
  163.  
  164.  
  165.  
  166. cout<<"Allergies: "<<Allergies<<endl;
  167. if
  168. (Allergies=='y' || Allergies=='Y')
  169. {
  170. cout<<"Patient is allergic to:"<<AllergiesSpecification<<endl;
  171.  
  172. }
  173. else if (Allergies =='n' || Allergies=='N')
  174. {
  175. cout<<endl;
  176. }
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183. cout<<"HPI: "<<HPI<<endl;
  184. outputFile<<"HPI: "<<HPI<<endl;
  185.  
  186. cout<<"Injured body parts: "<<IBP<<endl;
  187. outputFile<<"Injured body parts: "<<IBP<<endl;
  188.  
  189. cout<<"Mechanism of injury:"<<MOFI<<endl;
  190. outputFile<<"Mechanism of injury:"<<MOFI<<endl;
  191.  
  192. cout<<"Complaints: "<<Complaints<<endl;
  193. outputFile<<"Complaints: "<<Complaints<<endl;
  194.  
  195. cout<<"Any work up to date?"<<AWUTD<<endl;//if statement to show correct output
  196. if
  197. (AWUTD=='y' || AWUTD=='Y')
  198. {
  199. cout<<"Work up to date includes:"<<AWUTDspecification<<endl;
  200. }
  201. else if (AWUTD =='n' || AWUTD=='N')
  202. {
  203. cout<<endl;
  204. }
  205.  
  206. outputFile.close();
  207. };
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
hurbano is offline Offline
50 posts
since Sep 2008
Apr 11th, 2009
0

Re: Help With Final Output

c++ Syntax (Toggle Plain Text)
  1. outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
You output what outputFile returns. This line should be
c++ Syntax (Toggle Plain Text)
  1. outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;
Last edited by unbeatable0; Apr 11th, 2009 at 1:51 pm.
Reputation Points: 42
Solved Threads: 13
Junior Poster in Training
unbeatable0 is offline Offline
90 posts
since Sep 2008
Apr 11th, 2009
0

Re: Help With Final Output

Actually this:
C++ Syntax (Toggle Plain Text)
  1. outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;


is the same as this:
C++ Syntax (Toggle Plain Text)
  1. outputFile<<"Name: "<<Pname<<"\t\t"<<"Date:"<<TDate<<endl;
Last edited by tux4life; Apr 11th, 2009 at 2:04 pm.
Reputation Points: 2125
Solved Threads: 243
Postaholic
tux4life is offline Offline
2,105 posts
since Feb 2009
Apr 11th, 2009
0

Re: Help With Final Output

ah thats true because the \t is a "tab" right
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
hurbano is offline Offline
50 posts
since Sep 2008
Apr 11th, 2009
0

Re: Help With Final Output

Hello..:p..Thats rite..
Last edited by cikara21; Apr 11th, 2009 at 2:25 pm.
Reputation Points: 47
Solved Threads: 69
Posting Whiz
cikara21 is offline Offline
340 posts
since Jul 2008
Apr 11th, 2009
0

Re: Help With Final Output

can you modify the font coming out to the word document throught the program?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
hurbano is offline Offline
50 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: long doubles
Next Thread in C++ Forum Timeline: bug fix





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC