At the moment s is just an uninitialized pointer. It does not point to a valid block of memory, therefore you can't safely write anything to it.

You will find it much, much easier to define s as a std::string and use the <iostream> library for reading/writing, than to fix the problem with s. Fixing the problem with s as it is would be pretty easy for someone who knows C well, but it doesn't sound like you do and thus you are likely to have trouble. The C++ string and IO methods are much more intuitive.