/* This program provides several examples of incorrect operations on pointers. Try to compile and run the program as is. Note that the compiler will return several warnings and errors. You should make sure to identify the reasons for these. Next, try commenting out the code that has errors (not the warnings), then recompile and run the program. You should notice that the program fails and produces a segmentation fault (a catastrophic failure!). Look at the code that produced warnings to understand what code is causing this and why. You can try commenting out all the code that produces warnings and re-enabling it one line at a time. */ #include int main(void) { int a, b, *p1, *p2; a = 30; b = 50; p1 = &a; p2 = &b; printf("%d %d %d %d %d %d\n", a, b, *p1, *p2, p1, p2); p1 = &35; p1 = *35; p1 = 35; a = &b; a = *b; *a = *p1; &p1 = p2; a = p2; a = **p2; p1 = b; p1 = &p2; p1 = *p2; a = *b; *p1 = p2; *p1 = &a; return 0; }