# Homework 36: C++ I/O, string, and vectors

Name: _____________________________________________ Alpha: ___________________

• Due before class on Monday, April 24
• This homework contains code to be submitted electronically. Put your code in a folder called hw36 and submit using the 204sub command.
• This is an electronic homework and you do not need to print out anything to turn in during class.

# Assignment

1. Required reading: Sections 6 (I/O) and 7 (String and Vector) from the Unit 10 notes.
2. Write a C++ program called longword.cpp that reads in strings until the user types "STOP", and then reports the longest string that was entered.

You should use the C++ libraries <iostream>, <string>, and <vector>, and must not use any of that old C stuff like scanf or char arrays. (Note, it is possible to solve this problem without using any arrays or vectors, but I really want you to use a vector of strings anyway to get the practice.)

Example runs:

roche@ubuntu$./longword Enter words and then STOP: hello darkness my old friend STOP The longest word is darkness roche@ubuntu$ ./longword
Enter words and then STOP:
i've come to talk with you again STOP
The longest word is again