montimaj

Array of Ptrs

Sep 25th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. typedef struct array {
  4.   int *key;
  5. }array;
  6. int main() {
  7.   int j=10,i=2;
  8.   array *a=(array *)malloc(3*sizeof(array));
  9.   (a+i)->key=&j;
  10.   printf("%d\n",*((a+i)->key));
  11.   free(a);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment