// ptr2.cpp // Test program showing simple pointer arithmetic // 1/28/03, Ray S. Babcock // #include using namespace std; int main(void) { char my_char[2]={'a','b'}; short my_short[2]={0}; int my_int[2]={0}; double my_double[2]={0}; char * char_ptr = &my_char[0]; short * short_ptr = &my_short[0]; int * int_ptr = &my_int[0]; double * double_ptr = &my_double[0]; cout << "char_ptr = " << hex << (int)char_ptr << endl; char_ptr++; cout << "char_ptr = " << hex << (int)char_ptr << endl << endl; cout << "short_ptr = " << short_ptr << endl; short_ptr++; cout << "short_ptr = " << short_ptr << endl << endl; cout << "int_ptr = " << int_ptr << endl; int_ptr++; cout << "int_ptr = " << int_ptr << endl << endl; cout << "double_ptr = " << double_ptr << endl; double_ptr++; cout << "double_ptr = " << double_ptr << endl; cout << "That's all folks" << endl; }