Random commentary about C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
Depends on the compiler. Many modern compilers store string literals in read-only memory. Any modification will result in access violation exception. We can catch such exceptions using kernel API like installExceptionHandlers() if supported.There are few compilers that store the string literals in RW memory. The program works as expected in such cases.