E-mail files, part II: Printing messages

Due Monday 1/22/01, by 5:00PM. Submit your .cpp file via HSP .

Your first programming assignment got you started processing your raw e-mail inbox. In this assignment, you'll refine that program to take input from a file using a "file stream" rather than cin, and to display the contents of e-mail messages that are requested by the user.

To learn more about file input and output, read section 5.1 of your textbook. You might also find the programs fileInput1.cpp and files.cpp helpful.

The task

For this assignment, start with the program email2.cpp. This program has a main() and four functions. The main program and one of the functions have been written already. You should not need to make any changes to main() or OpenEmailFile().

The finished program should do the following:

  1. Ask the user for the name of an e-mail file.
  2. Print a numbered list of the "From:" and "Subject:" lines for the messages in the e-mail file.
  3. Ask the user for a message number.
  4. If the user's message number is 0, quit.
  5. Otherwise, print the given message and go back to step 2.

Here's an example session with the finished program:


	What is the name of the mailbox? tempMailbox

	1.
	From: Diane Caribou 
	Subject: Re: Lichen vs. grass

	2.
	From: Joan Elk  
	Subject: Re: Antler care

	3.
	From: "David R. Moosicant" 
	Subject: Re: Database course proposal

	4.
	From: Eleanor Emu 
	Subject: Re: feathers

	5.
	From: Andrew Qudu 
	Subject: artiodactylism

	
	Message number (0 to quit): 5


	Return-Path: 
	Received: from caesar.acns.carleton.edu (Caesar.ACNS.Carleton.edu [137.22.1.26])
	by mathcs.carleton.edu (8.9.3/8.9.3) with ESMTP id RAA17347
	for ; Tue, 16 Jan 2001 17:45:41 -0600
	Received: from mail.ungulates.com ([208.42.17.1])
	by carleton.edu (PMDF V5.2-32 #36754)
	with SMTP id <0G7A0042R1SMW7@carleton.edu> for jondich@mathcs.carleton.edu
	(ORCPT rfc822;jondich@carleton.edu); Tue, 16 Jan 2001 16:43:35 -0600 (CST)
	Received: from RBDOMAIN-Message_Server by mail.ungulates.com	with
	Novell_GroupWise; Tue, 16 Jan 2001 16:44:34 -0600
	Date: Tue, 16 Jan 2001 16:44:13 -0600
	From: Andrew Qudu 
	Subject: artiodactylism
	To: jondich@carleton.edu,
	MIME-version: 1.0
	X-Mailer: Novell GroupWise 5.5.2
	Content-type: text/plain; charset=US-ASCII
	Content-disposition: inline
	Content-Transfer-Encoding: 8bit
	X-MIME-Autoconverted: from quoted-printable to 8bit by mathcs.carleton.edu id RAA17347


	I have an even number of toes on each foot.  Do you?
	If not, what's odd-toed life like?

	Yours most sincerely,

	A. Qudu

	Hit return when you're ready for the list again.

	[etc.]

We will walk through the program in class on 1/17/01.

Have fun, start early, and keep in touch.



Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu