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";
More Related Contents:
- How to get the real and total length of char * (char array)?
- Why is sizeof giving incorrect number of bytes in C++?
- Something went wrong with passing pointer to a function
- What is array to pointer decay?
- How do I use arrays in C++?
- Passing a 2D array to a C++ function
- Return array in a function
- Are arrays Pointers? [duplicate]
- Why does cout print char arrays differently from other arrays?
- Address of an array
- Determine the size of a C++ array programmatically?
- Returning arrays from a function in c++
- C/C++ int[] vs int* (pointers vs. array notation). What is the difference?
- May I take the address of the one-past-the-end element of an array? [duplicate]
- What is the purpose of allocating a specific amount of memory for arrays in C++?
- A pointer to 2d array
- pointer to array c++
- Casting pointer to Array (int* to int[2])
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)? [closed]
- Pointer interconvertibility vs having the same address
- How do I create an array of pointers?
- array of pointers as function parameter
- In C/C++, is char* arrayName[][] a pointer to a pointer to a pointer OR a pointer to a pointer?
- Function returning array but main showing garbage [duplicate]
- how do arrays work internally in c/c++
- difference between pointer to an array and pointer to the first element of an array
- Concatenate char arrays in C++
- How can a char pointer be initialized with a string (Array of characters) but an int pointer not with an array of integer? [duplicate]
- Assign a string literal to a char* [duplicate]
- int *array = new int[n]; what is this function actually doing?