Created
October 24, 2014 05:23
-
-
Save honux77/12677042314035c951f2 to your computer and use it in GitHub Desktop.
various pointer
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 <stdlib.h> | |
| #include <stdio.h> | |
| int foo(int x) { return 1; } | |
| int main(void) { | |
| int *ptr[2]; | |
| int (*ptr2)[2]; | |
| int(*ptr3)(int); | |
| int x = 10; | |
| int arr[] = { 1, 2, 3, 4}; | |
| int arr2[3][2] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; | |
| //ptr is size 2 array of int pointer | |
| ptr[0] = &x; | |
| ptr[1] = arr; | |
| ptr[0] = arr2[0]; //ok? | |
| //ptr2 is pointer of size two int array (n * 2 2d array) | |
| ptr2 = arr2; | |
| //ptr3 in function pointer | |
| ptr3 = foo; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment