[Solved] Pointers On C exercises 6.18-2, my solution does not work


Both source and chars are pointers to string literals, you can’t modify a string literal, as per the language rules, the behavior of a program where this is done is undefined. source must be declared as a char array:

char source[] = "hello, people.";

This way a copy of the string is stored in the array and, as such, it is modifiable.

I’m going to guess that your book must talk about string literals and how you should handle them. If that is not the case, we can’t really call it the book.

solved Pointers On C exercises 6.18-2, my solution does not work