// demoString.cc   Demo use of C++ string type
// P. Conrad for CISC220, 06J


#include <iostream>
using std::cout;
using std::endl;

#include <string> // not <cstring> !!!
using std::string;

int main(int argc, char * argv[])
{
  string x; // default constructor (empty string)
  string fname("Phill"); // constructor that takes a const char * const
  string lname("Conrad"); // ditto
  string fullname = fname + " " + lname; // string concatenation

  cout << "x =        " << '"' << x     << '"' << endl;
  cout << "fname =    " << '"' << fname << '"' << endl;
  cout << "lname =    " << '"' << lname << '"' << endl;
  cout << "fullname = " << '"' << lname << '"' << endl;

  if (x=="") // you can just use == with string, no need for strcmp
    cout << "x is a null string" << endl;
  else
    cout << "x is NOT a null string";
     
  fname = "Fred"; // You can just do assignment too, no need for strcpy

  cout << "fname =    " << '"' << fname << '"' << endl;

  string progName = argv[0]; // you can initialize from a char *
  cout << "progName = " << progName << endl;

  // if argv[1] is a NULL pointer, a problem will arise here

  string firstArg = argv[1];
  cout << "firstArg = " << firstArg << endl;
  
  return 0;

}
