Ok, on line 11, you assign p to be the address of the constant char* "abc". Then, inside the function, you attempt to modify that to become 'x', which is impossible, since "abc" is in read-only memory. You would either a) need to use dynamic allocation to create your C-string, or b) use an std::string and not have to worry about this kind of stuff.