http://d.pr/f/FIjf
Please check up main.c. I assigned a string as char *s3 = "0,9,8,7,6,5,4,3,2,1"; and there will be a SIGSEGV at running. When I de-annotate this line, then there is no SIGSEGV. So why does this string assignment lead to SIGSEGV?
http://d.pr/f/FIjf Please check up main.c. I assigned a string as char *s3 = 0,9,8,7,6,5,4,3,2,1;
Share
Most likely you are modifying a string literal resulting in Undefined Behavior(UB).
s3points to a string literal stored in read only implementation defined memory and any attempt to modify this string literal results in Undefined Behavior. In fact you are lucky that your code crashes because UB does not necessarily mandate a crash, but it can give you weird or literally any result.