// strings_02.cpp -- storing strings in an array
#include <iostream>
#include <cstring>  // for the strlen() function
int main()
{
    using namespace std;
    
    const int Size = 15;
    char name1[Size];            // empty array
    char name2[Size] = "Jonah";  // initialized array
 
    // printing out name2
    cout << "Hi, I'm " << name2;
    
    // asking user for their name and storing it char array: name1
    cout << ". What's your name?\n";
    cin >> name1;

    // printing out:
    // your name
    cout << name1 << ", your name has ";
    // numbers of letters in array with strlen()
    cout << strlen(name1) << " letters and is stored\n";
    // number of bytes in array
    cout << "in an array of " << sizeof(name1) << " bytes.\n";
    // your initials
    cout << "Your initial is " << name1[0] << ".\n";
    
    // setting 4th spot in array to NULL, will cut off string
    name2[3] = '\0';                // null character

    // print out cut off string - keeps on printing chars until
    // it sees a NULL character
    cout << "Here are the first 3 characters of my name: ";
    cout << name2 << endl;
}
