// cstring.cpp
// Demonstration of C-style strings
// P. Conrad, Mar 2004 for CISC181


#include <iostream>
using std::cout;
using std::cerr;
using std::cin;
using std::ios;
using std::endl;
using std::flush;

#include <cstdlib> // for prototype of exit() function



int main(void)

{

  const int FULLNAME_SIZE = 30;

  char firstName[10]; // a character array to store a first name
  char lastName[20];  // a character array to store a last name
  char fullName[FULLNAME_SIZE];  // putting them both together
                                 // using a const int is better style

  cout << "Please enter your firstName: " << flush;
  cin >> firstName;
  
  cout << "Please enter your lastName: " << flush;
  cin >> lastName;


  cout << "\n"
       << "Last name: " << lastName << "\n"
       << "First name:" << firstName << "\n"
       << "\n";
  
  cout << "Greetings, " << firstName << " " << lastName << "!\n";

  cout << "\n" 
       << "Now I will try to read in your two names together: " << endl;

  cout  << "Please enter your first and last name: " << flush;


  cin >> std::ws; // skip over white space after lastName (e.g., newline);
  cin.getline(fullName, FULLNAME_SIZE, '\n');

  // notice the "dot" between cin and getline
  // this is called "dot notation"

  cout << "Your full name, read in all at once, is " 
       << fullName << ".\n"
       << "\n" 
       << "That's all for now!\n" << endl;
  
  return 0;

}
    

