1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/*
User will enter their name and their phone number into program and have the program then strip out the name,
placing it into a column in a table, and then stripping the phone number from format: xxx-xxx-xxxx, and putting
area code in column 2, and rest of phone number in column 3 (Perhaps even add a memo to each number, such as mobile or home?, or stripping initial from first / last name
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
// table: 5x4 (rowsxcolumns) Columns: 1. Full Name, 2. Initials, 3. Area Code (000), 4. Phone Number (000-0000)
string table[5][4];
// variables of contacts
string name_first;
string name_last;
string phone_number;
string name_full;
// enter their first & last names - make this a function?
cout << "Enter a name (first space last): ";
getline(cin,name_full);
// enter phone number
cout << "Enter a phone number, in the format: 000-000-0000: ";
getline(cin,phone_number);
// display text
cout << "\nFull name: " << name_full << endl;
cout << "Phone number: " << phone_number << endl;
// get characters in string
char first = name_full.at(0);
char last = name_full.at(name_full.find(" ",0) + 1);
/* This finds the character " " between the first and last names, and then
gets the character +1 after this position. It utilitzes a function within another
*/
cout << "\nFirst letter in the FIRST name: " << first << endl;
cout << "\First letter of the LAST name: " << last << endl;
// place name into table
table[0][0] = name_full;
// place initials into table
//name_full.insert(name_full.at(name_full.find(" ",0) + 1));
//name_full.insert(6,first);
// char combine = last(first);
string initials = "first" + "last";
table[0][1] = initials;
// display table
cout << "\nTable data which has been entered" << endl;
cout << table[0][0] << " " << table [0][1] << endl;
cin.get();
cin.ignore();
return 0;
}
|