Advertisement
ivanria

c const

Jul 4th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4.  
  5. #ifdef SEGFAULT
  6. char * const s = "str";
  7. #endif
  8.  
  9. void segfault(char **p)
  10. {
  11.     *p = "hello";
  12. }
  13.  
  14. int main(void)
  15. {
  16. #ifndef SEGFAULT
  17.     char * const s = "str";
  18. #endif
  19.     segfault((char **)&s);
  20.     printf("%s\n", s);
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement