String literals are stored in a read-only memory section. Any attempt to modify the contents of a string literal causes an Undefined Behavior (segmentation error in most implementations).
Use an array of characters rather
char str[] = "HelloGuys";
source
share