Created
December 10, 2014 13:17
-
-
Save ramntry/e37fa85edbd633c1749f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| char buf[32] = "Hello World"; | |
| char *bufptr = buf; | |
| void f(char **x) { | |
| printf("%s\n", *x); | |
| } | |
| int main() { | |
| f(&bufptr); // OK; OK | |
| f(&buf); // Warning; Segmentation Fault | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
main.c: In function ‘main’: main.c:12:3: warning: passing argument 1 of ‘f’ from incompatible pointer type [enabled by default] f(&buf); // Warning; Segmentation Fault ^ main.c:6:6: note: expected ‘char **’ but argument is of type ‘char (*)[32]’ void f(char **x) { ^ ramntry@roman-tereshin-GS60:~/tmp/carray$ ./a.out Hello World Segmentation fault (core dumped)