Printf ubuntu Segmentation fault (core dumped)

Posted by Someone on Stack Overflow See other posts from Stack Overflow or by Someone
Published on 2012-12-15T16:53:57Z Indexed on 2012/12/15 17:03 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

I have this code:

int a;
printf("&a = %u\n",(unsigned)&a);
printf("a\n");
printf("b\n");
printf("c\n");
printf("d\n");

I tried to print the pointer of a variable.
But it fail on the row printf("a\n"); and says Segmentation fault (core dumped)
Output:

&a = 134525024
Segmentation fault (core dumped)

When I remove the row printf("&a = %u\n",(unsigned)&a); from the code, its success. Output:

a
b
c
d

What worng in my code?

© Stack Overflow or respective owner

Related posts about c

    Related posts about ubuntu