fig05_04.cpp

来自「经典vc教程的例子程序」· C++ 代码 · 共 25 行

CPP
25
字号
// Fig. 5.4: fig05_04.cpp
// Using the & and * operators
#include <iostream.h>

int main()
{
   int a;        // a is an integer
   int *aPtr;    // aPtr is a pointer to an integer

   a = 7;
   aPtr = &a;    // aPtr set to address of a

   cout << "The address of a is " << &a
        << "\nThe value of aPtr is " << aPtr;

   cout << "\n\nThe value of a is " 
        << "\nThe value of *aPtr is " << *aPtr;

   cout << "\n\nShowing that * and & are inverses of "
        << "each other.\n&*aPtr = " << &*aPtr
        << "\n*&aPtr = " << *&aPtr << endl;
   return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?