Ch2_4_s11

Ch2_4_s11 - cin >> age...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 2.4: Input/Output 1 Next Slide Previous Slide Example statements for text file output 1. ofstream output ( "data.txt“ ) ; variable1 = 6 ; cout << "variable1 = " << variable1 << endl ; output << "variable1 = " << variable1 << endl ; 2. ofstream stats ( "age_weight.txt“ ) ; cout << "Enter your age and weight: “ ;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cin &gt;&gt; age &gt;&gt; weight ; stats &lt;&lt; age &lt;&lt; &quot; &quot; &lt;&lt; weight &lt;&lt; end l; 3. ofstream out ( &quot;information.txt ) ; cout &lt;&lt; &quot;Enter your age and weight\nAge = ; cin &gt;&gt; age ; cout &lt;&lt; &quot;Weight = ; cin &gt;&gt; weight ; out &lt;&lt; &quot;Your age: &quot; &lt;&lt; age ; out &lt;&lt; &quot;\nYou weight: &quot; &lt;&lt; weight &lt;&lt; &quot; pounds&quot; &lt;&lt; endl ;...
View Full Document

Ask a homework question - tutors are online