String example #2

//string2.cpp


#include <iostream>
#include <string> //needed to use strings!



using namespace std;
int main()
{
	string first_name;
	string last_name;
	string full_name;

	cout << "\n\tEnter your first name:  ";
	cin >> first_name;

	cout << "\n\t\tEnter your last name:  ";
	cin >> last_name;

	full_name = first_name + last_name; //concatenate the strings

	cout << "\nYour name is: \n\t";
	cout << full_name <<endl;

	//How to have some fun with strings!
	//Because the string class stores data in an array, we can change
	//parts of the string if we know which position we want to change

	string first= "Seymour " ;
	string last = "Butts" ;
	
	char change_it = last[0];	//create a char variable equal to first
									//letter in the last name string
	last.at(0) = 'M';			//change first letter in last name to M

	string new_name = first + last;
	cout << "Here's another example:";
	cout << new_name << endl;


	return 0;

}

/*
        Enter your first name:  Barb

                Enter your last name:  Sanchez

Your name is:
        BarbSanchez
Here's another example:Seymour Mutts
Press any key to continue
*/