#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;

int main(){
	char myStr[40];
	char myOtherStr[] = "Hello World!";
	char anotherStr[] = {'G','o','o','d','b','y','e','!'};
	string yetAnotherStr = "Feliz Navidad!";

	// setlocale(LC_ALL, "en_US.UTF-8");

	cout << "Value of myStr (uninitialized): " << myStr << endl; 

	// strcpy(destination,source)
	strcpy(myStr,myOtherStr);
	cout << "Value of myStr (after 1st strcpy: " << myStr << endl;
	cout << "Length of myStr: " << strlen(myOtherStr) << endl;
	cout << "Size of myStr (bytes): " << sizeof(myOtherStr) << endl;

	for(int i = 0; i < strlen(myStr); i++){
		cout << right << setw(2) << i << ": " << myStr[i] << endl;
	}

	strcpy(myStr,"Próspero año y felicidad");
	cout << "\nValue of myStr (after 2nd strcpy): " << myStr << endl;
	cout << "Length of myStr: " << strlen(myStr) << endl;
	cout << "Size of myStr (bytes): " << sizeof(myStr) << endl;

	for(int i = 0; i < strlen(myStr); i++){
		cout << right << setw(2) << i << ": " << myStr[i] << endl;
	}	

	cout << "\nValue of yetAnotherStr: " << yetAnotherStr << endl;
	cout << "Length of yetAnotherStr: " << yetAnotherStr.length() << endl;
	cout << "Size of yetAnotherStr (bytes): " << sizeof(yetAnotherStr) << endl;	

	// two ways to mix and match types:
	// stream:
	cout << "\n" << yetAnotherStr << "\n" << myStr << endl;
	// concatenation:
	cout << "\n" << yetAnotherStr + "\n" + myStr << endl;

	return 0;
}
