Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. // blah.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. void main() {
  11.     int year = 9;
  12.  
  13.     cout << "The value of year is :\t" << year << endl;
  14.     cout << "The addr of Year is :\t" << &year << endl;
  15.    
  16.  
  17.  
  18.     char name[] = "Monkeys make horrible employees.  and they never share their bananas!";
  19.     char addr[] = "a";
  20.  
  21.     cout << "the name is : " << name << endl;
  22.  
  23.     cout << "the address of name is : " << &name << endl;
  24.     cout << "The length of name is: " << sizeof(name) << endl;
  25.  
  26.     cout << "The addr is: " << addr << endl;
  27.     cout << "The addr of addr is: " << &addr << endl;
  28.     cout << "The length of addr is: " << sizeof(addr) << endl;
  29.     system("pause");
  30.  
  31.     char *pBetty, *pJane, *pConnie;
  32.    
  33.     cout << "The address Betty is stored in is: ";
  34.     printf("0x%08x\n", &pBetty);
  35.     cout << "The address Jane is stored in is: ";
  36.     printf("0x%08x\n", &pJane);
  37.     cout << "The address Connie is stored in is: ";
  38.     printf("0x%08x\n", &pConnie);
  39.  
  40.     pBetty = NULL;
  41.     pJane = NULL;
  42.     pConnie = NULL;
  43.  
  44.     pBetty = new char;
  45.     pJane = pBetty;
  46.     pConnie = pBetty;
  47.  
  48.     *pBetty = 'a';
  49.  
  50.     delete(pBetty);
  51.    
  52.     pBetty = NULL;
  53.  
  54.     *pJane = 'k';
  55.  
  56.  
  57.     string *pSilly = new string();
  58.  
  59.  
  60.     system("pause");
  61.  
  62.     return;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement