can’t modify char* – Memory access violation

String literals are stored in read only section of memory. Any attempt to modify the contents of a string literal invokes Undefined Behaviour (segmentation fault on most implementations).

Use an array of characters rather

char str[] = "HelloGuys";

Leave a Comment