Advertisement
Guest User

Pointers

a guest
Nov 22nd, 2014
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. // initial vars
  10. char Target[50] = "-X- Teknogods -X-";
  11. char space1[60] = "- I am between pointer one and Teknogods -";
  12. char *Pointer1 = NULL;
  13. char space2[60] = "- I am between pointer one and two -";
  14. char **Pointer2 = NULL;
  15. char space3[60] = "- I am between pointer two and three -";
  16. char ***Pointer3 = NULL;
  17. char space4[30] = "- I am the end -";
  18.  
  19. // set pointers
  20. Pointer1 = &Target[0];
  21. Pointer2 = &Pointer1;
  22. Pointer3 = &Pointer2;
  23.  
  24. // show pointers and whats inside
  25. cout << "sTarget contains: " << Target << endl;
  26. cout << "Address of sTarget is: " << &Target << endl;
  27. cout << "---------------------------------------------" << endl;
  28. cout << "Pointer1 is at address: " << &Pointer1 << endl;
  29. cout << "Pointer1 contains: " << (void *)Pointer1 << endl;
  30. cout << "---------------------------------------------" << endl;
  31. cout << "Pointer2 is at address: " << &Pointer2 << endl;
  32. cout << "Pointer2 contains: " << (void *)Pointer2 << endl;
  33. cout << "---------------------------------------------" << endl;
  34. cout << "Pointer3 is at address: " << &Pointer3 << endl;
  35. cout << "Pointer3 contains: " << (void *)Pointer3 << endl;
  36.  
  37. system("pause");
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement