Your code attempts to modify a string literal which is not allowed in C or C++ If you change:
char *s = "hello";
to:
char s[] = "hello";
then you are modifying the contents of the array, into which the literal has been copied (equivalent to initialising the array with individual characters), which is OK.