lab07 - initials, which are single characters, you must...

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

View Full Document Right Arrow Icon
Lab 07: String Class Name Manipulation Last Modified 02/12/2009 Key Concept: Accessing Characters from Strings, C++ String Class methods, C++ String Class concatenation Write a program that uses the C++ string class to convert names from the format " Last, First M. " to " First M. Last " and which also displays the user's initials. Read in the full name as a single string object (not in parts as in Lab 1). When extracting initials, use the [] operator. (There shouldn't be a comma in the converted name.) Remember to follow the IPO model. Hint When you concatenate strings, you must be adding onto an object that is a string. Thus, to build the string of
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: initials, which are single characters, you must concatenate those single characters with an existing string. Since string objects, by default, are the empty string, you can concatenate with it. Consider the following example: string output; // output string to be built from letters char first = 'A'; // first letter of output char second = 'B'; // second letter of output output = output + first + second; // build output Sample Interaction Enter your name in 'Last, First M.' format: Hogan, Douglas J. Reformatted name: Douglas J. Hogan Initials: DJH Submission Code Three sample runs (No discussion required this time)...
View Full Document

This document was uploaded on 02/10/2011.

Ask a homework question - tutors are online