Pointer assignment Problem

When i run the above program in gcc complier(www.codepad.org) i get the output as Disallowed system call: SYS_socketcall Could anyone please clear why this error/output comes?

int main() {
    int i=8;
    int *p=&i;
    printf("\n%d",*p);
    *++p=2;
    printf("\n%d",i);
    printf("\n%d",*p);
    printf("\n%d",*(&i+1));
    return 0;
}

what i have observed is i becomes inaccessible after i execute *++p=2;WHY?

Answers


When you do *p = &i, you make p point to the single integer i. ++p increments p to point to the "next" integer, but since i is not an array, the result is undefined.


Need Your Help

Benchmarking in Ruby

ruby benchmarking

I have been doing some benchmarking in Ruby and have the following results:

MySQL SUBSTR function with Join and IF conditions

php mysql sql join substr

I'll try to be as clear as possible to see if I can express my problem.