demo-getline - cout <<...

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

View Full Document Right Arrow Icon
// Demo of getline #include <iostream.h> #include <stdio.h> int main() { char inputLine[80]; char inputWord[20]; cout << "Type something" << endl; cin.getline(inputLine, 80); cout << "you typed:" << endl; cout << inputLine; cout << "Now type just one word: "; cin >> inputWord;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout &lt;&lt; &quot;Now type another line: &quot;; // without this commented-out line, bad things happen! //cin.ignore(80, '\n'); cin.getline(inputLine, 80); cout &lt;&lt; &quot;The word: &quot; &lt;&lt; inputWord &lt;&lt; endl; cout &lt;&lt; &quot;The line: &quot; &lt;&lt; inputLine &lt;&lt; endl; return 0; }...
View Full Document

Ask a homework question - tutors are online