"hello world"; will return a position in constant memory so you can't modify it, the proper way of declaring 's' should be this: constchar *s = "hello world";
If you want something you can modify you should mace 's' an array: char s[] = "hello world"; or, of course, a std::string
You can change values with pointers, you just need to own the memory you want to modify.
Some compilers may also allow the program you posted but that isn't a standard behaviour.