CH12 - An Introduction to Programming with C Fifth Edition...

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

View Full Document Right Arrow Icon
An Introduction to Programming with C++, Fifth Edition 12 - 1 Chapter 12 String Manipulation At a Glance Instructor’s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Topics Classroom Activities/Additional Projects Key Terms
Background image of page 1

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

View Full Document Right Arrow Icon
An Introduction to Programming with C++, Fifth Edition 12 - 2 Lecture Notes Chapter Overview This chapter covers topics related to string manipulation in C++. Topics include determining the number of characters in a string, accessing characters in a string, removing characters from a string, replacing and inserting characters in a string, searching a string for another string, and concatenating strings. Chapter Objectives After completing the chapter, the student will be able to: Determine the number of characters contained in a string Remove characters from a string Access characters in a string Replace characters in a string Insert characters within a string Search a string for another string Compare a portion of a string variable’s contents to another string Duplicate a character within a string variable Concatenate strings Perform string manipulation in .NET C++ Instructor Notes Manipulating Strings In many situations, it may be desirable for a program to manipulate, or process in some fashion, character and/or string data. Most programming languages provide built-in functions that make character and string manipulation a much easier task vs. the programmer writing his/her functions to perform this manipulation. Determining the Number of Characters Contained in a String In many programs, it is necessary to determine the number of characters contained in a string. In some programming languages, the number of characters contained in a string is referred to as the size of the string, while in others it is referred to as the length of the string. In C++, the length() function is used to determine how many characters are contained in a string. Figure 12-1 on page 683 shows the syntax and examples of the length() function.
Background image of page 2
An Introduction to Programming with C++, Fifth Edition 12 - 3 Removing Characters from a String An application may at times need to remove one or more characters from an item or data. In C+ +, you can use the erase() function to remove one or more characters located anywhere in a
Background image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

CH12 - An Introduction to Programming with C Fifth Edition...

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

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