Modifying value of char pointer in c produces segfault?

The standard explicitly lists this as undefined behavior in §J.2: — The program attempts to modify a string literal (6.4.5) If you want to copy it into a local array, do: char a = "abc a is an array on the stack, and you can modify it freely.

The standard explicitly lists this as undefined behavior in §J.2: — The program attempts to modify a string literal (6.4.5) If you want to copy it into a local array, do: char a = "abc"; a is an array on the stack, and you can modify it freely.

Attempting to modify a string literal causes undefined behaviour.

There has to be. – Smoke Manmuscle Mar 4 at 4:49 1 @Smoke, no there is not. You need to copy the literal into an array that's not in read-only memory.

– Carl Norum Mar 4 at 4:50 Thanks that makes sense. – Smoke Manmuscle Mar 4 at 4:53.

The following code produces a segmentation fault on my system. I can't figure out why. Any help would be appreciated.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions