Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.  
  5. int a = 2;
  6. int b = 3;
  7. int* c = &a;
  8. int d = 2;
  9.  
  10. cout << " größe von int in byte: " << sizeof(int) << endl;
  11. cout << "größe von int* in byte: " << sizeof(int*) << endl;
  12. cout << "deklariert wurde nacheinander: int a, int b, int* c, int d\n\n" << endl;
  13. cout << " adresse von int a: " << uintptr_t(&a) << " (-" << sizeof(int) << ", korrekt)" << endl;
  14. cout << " adresse von int b: " << uintptr_t(&b) << " (-" << sizeof(int) << ", falsch?)" << endl;
  15. cout << " adresse von int* c: " << uintptr_t(&c) << " (-" << sizeof(int*) << ", falsch?)" << endl;
  16. cout << " adresse von int d: " << uintptr_t(&d) << endl;
  17. }
  18.  
  19. #######################
  20. größe von int in byte: 4
  21. größe von int* in byte: 8
  22. deklariert wurde nacheinander: int a, int b, int* c, int d
  23.  
  24.  
  25. adresse von int a: 140736349410284 (-4, korrekt)
  26. adresse von int b: 140736349410280 (-4, falsch?)
  27. adresse von int* c: 140736349410272 (-8, falsch?)
  28. adresse von int d: 140736349410268
  29.  
  30. Process returned 0 (0x0) execution time : 0.001 s
  31. Press ENTER to continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement