C-style strings don't work like that. A variable of type char* is a pointer, and as such it actually has to point to a valid memory location before you can modify information in it. I advise against using char* with cin anyway because there isn't a guarantee that what you input will actually fit in the buffer.

You have two possible solutions to this problem:

1) Use std::string for your string instead.
2) Turn strg into an array instead of a pointer, and use cin.getline(strg, XXX) where XXX is the length of your array.

No. It's unsafe, because as I stated before, there is no guarantee that the buffer will fit what you type into it. As you have it right now, strg will hold nine characters plus the terminating character ('\0'). If the user types a string that is ten characters or more, your program may behave erratically or it may crash, either instantly or somewhere down the road.

Instead of using cin >> strg;, you should use cin.getline(strg, 10); in this case, which will read a line of text that the user types, and makes sure not to fill your array anywhere past those ten characters that you can hold.