My bad!!I had assumed that the following excerpt from a notorious yet wildly popular book is totally valid C.But only today I was pointed out that it's ridden with UB (though I am yet to find how come it's so).Hence here's that particular section from the book.You will be doing me and many other "victims" like me a great favor if you can point out in a numbered manner what is wrong or UB with each particular statement,and the appropriate corrections for those.
char *p = "Hello" ; /* pointer is variable, so is string */
*p = 'M' ; /* works */
p = "Bye" ; /* works */
const char *q = "Hello" ; /* string is fixed pointer is not */
*q = 'M' ; /* error */
q = "Bye" ; /* works */
char const *s = "Hello" ; /* string is fixed pointer is not */
*s = 'M' ; /* error */
s = "Bye" ; /* works */
char * const t = "Hello" ; /* pointer is fixed string is not */
*t = 'M' ; /* works */
t = "Bye" ; /* error */
const char * const u = "Hello" ; /* string is fixed so is pointer */
*u = 'M' ; /* error */
u = "Bye" ; /* error */