ptr isn't allocated any space, so when you read in your string it goes to a random place in memory.
In your case, in this instance, it blows up.

Allocate some space, or just use a char array.
...