Advertisement
xathrya

Pointers Stuffs

Jan 12th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int x = 1, w = 2, v = 3, u = 4, t = 5;
  4. int z[5] = { 6, 7, 8, 9, 10 };
  5. int *s = &x;
  6.  
  7. int fungsi()
  8. {
  9.     return 10;
  10. }
  11.  
  12. int* fungsi1()
  13. {
  14.     return &v;
  15. }
  16.  
  17. int* fungsi2()
  18. {
  19.     return &u;
  20. }
  21.  
  22. int main()
  23. {
  24.     int **a = &s;
  25.     void *b = &w;
  26.     int *c[5] = { &x, &w, &v, &u, &t };
  27.     int (*d)[5] = &z;
  28.     int (*e)() = fungsi;    
  29.     int *(*f[2])() = { fungsi1, fungsi2 };
  30.    
  31.     int i;
  32.    
  33.     printf("**a       = %d\n", **a);
  34.     printf("*b        = %d\n", *((int*)b));
  35.     printf("*c[2]     = %d\n", *c[2]);
  36.     printf("*d[2]     = %d\n", (*d)[3]);
  37.     printf("e()       = %d\n", e());
  38.     printf("(*f[0])() = %d\n", *(f[0])());
  39.        
  40.    
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement