Ch3_PeekAndPutbackFunctions

Ch3_PeekAndPutbackFunctions - cin.putback(ch); //Line 7...

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

View Full Document Right Arrow Icon
//Functions peek and putback / #include <iostream> using namespace std; u int main() { char ch; cout << "Line 1: Enter a string: "; //Line 1 cin.get(ch); //Line 2 cout << endl; //Line 3 cout << "Line 4: After first cin.get(ch); " << "ch = " << ch << endl; //Line 4 cin.get(ch); //Line 5 cout << "Line 6: After second cin.get(ch); " << "ch = " << ch << endl; //Line 6
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.putback(ch); //Line 7 cin.get(ch); //Line 8 cout &lt;&lt; &quot;Line 9: After putback and then &quot; &lt;&lt; &quot;cin.get(ch); ch = &quot; &lt;&lt; ch &lt;&lt; endl; //Line 9 ch = cin.peek(); //Line 10 cout &lt;&lt; &quot;Line 11: After cin.peek(); ch = &quot; &lt;&lt; ch &lt;&lt; endl; //Line 11 cin.get(ch); //Line 12 cout &lt;&lt; &quot;Line 13: After cin.get(ch); ch = &quot; &lt;&lt; ch &lt;&lt; endl; //Line 13 return 0; }...
View Full Document

Ask a homework question - tutors are online