Skip to content

Instantly share code, notes, and snippets.

@honux77
Created October 24, 2014 05:23
Show Gist options
  • Select an option

  • Save honux77/12677042314035c951f2 to your computer and use it in GitHub Desktop.

Select an option

Save honux77/12677042314035c951f2 to your computer and use it in GitHub Desktop.
various pointer
#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