char myArray[100];This creates an array of 100 chars, each char with no defined value yet. myArray[i] will never be '\n' because that character is not fed into a string when using cin >>.
// Example program
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
char arr[100];
// http://www.cplusplus.com/reference/istream/istream/getline/
// "A null character ('\0') is automatically appended to the written sequence"
cin.getline(arr, 100);
cout << arr << '\n';
}
Your second code isn't necessarily wrong depending on context, but it does force you to type in 100 characters.