This code compiles with no errors under cygwin and under linux. But when i run it, it runs with no errors in cygwin but it core-dumps under linux.
can someone shed some light about the memory management of these systems that would explain why the different behaviors?
#include <stdio.h>
void foo(char *p){
p[0]='A';
}
void main(){
char *string ="Hello world!";
foo(string);
printf("%s\n", string);
}
Thanks for the answers and makes sense that behavior is not defined, however i was interested in the differences of the underlying systems that lead to these 2 distinct undefined behaviors. I imagine its related to how they manage memory but looking for someone who is familiar with the internals who can explain why one ends up crashing while the other one does not.