You cannot get input to pointer s without first allocating it some memory. What you're doing is attempting to store to whatever memory address s points to, which could be pretty random!
If you've not allocated the memory, you don't control it. If you don't control it, you should not be trying to modify it.
And, when you allocate memory to hold a copy of a string, you need to use strlen( source ) +1 as the size of the new array - you've got to allow for the NULL terminator character.
Reputation Points: 1268
Solved Threads: 228
Posting Virtuoso
Offline 1,895 posts
since Aug 2007