thenewboston

C Programming Tutorial - 42 - Pointers

Aug 22nd, 2014
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6.  
  7. int main()
  8. {
  9.     int tuna = 19;
  10.  
  11.     printf("Address \t Name \t Value \n");
  12.  
  13.     // &tuna means "the memory address of tuna"
  14.     printf("%p \t %s \t %d \n", &tuna, "tuna", tuna);
  15.  
  16.     // pointers are special variables that hold the memory address of other variables
  17.     int * pTuna = &tuna;
  18.  
  19.     // now you can use pTuna instead of &tuna
  20.     printf("%p \t %s \t %d \n", pTuna, "tuna", tuna);
  21.  
  22.     // here is the info for pTuna
  23.     printf("%p \t %s \t %p \n", &pTuna, "pTuna", pTuna);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment