/* Copyright: 1999-2000, All rights reserved. Program: strings Version: 1.3 Created: 9/25/99 Revised: 10/10/00 File: strings.cpp Programmer: C. S. Tritt, Ph.D. Course: CS-150 Assignment: Example Compiler: Microsoft Visual C++ 6.0 Target: Win32 Description: This program attempts string assigment. Revisions: There have been no major revisions of this program. Constants and Variables: See code for constant and variable descriptions. */ // Included files. #include // Required for stream output (cout). #include // Required for string class. using namespace std; int main() { const string first("Charles"); // Constructor call style initialization. const string last = "Tritt"; // Assignment style initialization. string mi = "S."; // Who knows, I might change my middle initial. string whole; whole = first + " " + last; cout << whole << " is my name.\n"; whole.insert(7, " " + mi); // Insert a space and middle initial. cout << whole << " is also my name.\n"; cout << whole.find("Tr") << " is the starting position of \"Tr\" in whole.\n"; cout << whole.length() << " is the length of whole.\n"; cout << whole.substr(4,6) << " is substring 4, 6 of whole.\n"; return 0; }