1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
#include <limits>
using namespace std;
int main()
{
char alphabet[26] = {'a', 'b', 'c', 'd', 'e','f','g','h', 'i', 'j',
'k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int n;
char * letterpointer=alphabet;
cout << "Enter a number between 0 and 27 and I will tell you \nwhat letter holds that position in the alphabet... " << endl;
cin >> n;
cout << endl;
cout << "Position " << n << " of the alphabet is occupied by: " << letterpointer[n - 1] << endl;
cout << "The current memory address of " << letterpointer[n-1] << " is: ";
cout << (void*)letterpointer[n-1] << endl;
cout << endl;
delete letterpointer;
cin.sync();
cout<<"Press Enter Key To Exit"<<endl;
cin.ignore( numeric_limits<streamsize>::max(),'\n' );
return 0;
}
|