For
std::cin
you should use >> instead of <<.
Since 'a' is the variable you used to loop the for-loop, you should rename the string 'a' that you use inside the loop to avoid name conflicts. And you want to declare a variable before using it(look at the first 2 lines of the for-loop again).
And C++ starts a 0, so to access the first element, you would do something like age[0].
Now on the main problem. When the user enters in "Michael Jackson", only "Michael" is stored into the string. That messes things up.
One way to fix this is using the getline function:
http://www.cplusplus.com/reference/istream/istream/getline/
To use it, you create a character
char
array of an arbitrary size(256 should be more than enough). And you use it kind of like this:
cin.getline(name, 256) //where name is the char array mentioned
So when the user enters in a name like "Bobby John", the whole name is stored. name[0] would equal "B", name[1] = "o", etc.
But if you
cout << name,
, it should just print out the whole name. You don't have to print out every char individually.