In Class Exercise 2

In Class Exercise 2 - CS 171 In Class Exercise 2 This code...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 171 In Class Exercise 2 This code is correct. ignore() and clear() are used because of the incompatibilities between >> and getline(). ( >> doesnt read the end of line) Your task is to complete the output below. (Hint: Each line should be different). You are given the first four lines and the last line of output from Visual Studio. Your task is to complete the output below, consisting of lines 5, 6, 7, and 8. The cin.ignore() and cin.clear() have the effect of giving a fresh start for the new entry. (In case, unread entry characters were left from the previous entry.) Enter string with blanks: aa bb cc Reenter string: aa bb cc Reenter string again: aa bb cc Reenter string one more time: aa bb cc Press any key to continue . . . Group Members: // getline.cpp // Furman Haddix // Compare get, getline, and >> invocations #include <iostream> #include <string> using namespace std; int main() { string s1, s2; char c1, c2, c3, c4, c5; char d1, d2, d3, d4, d5; cout << "Enter string with blanks: ";...
View Full Document

Page1 / 2

In Class Exercise 2 - CS 171 In Class Exercise 2 This code...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online