// 11_1.cpp : Defines the entry point for the console application. // 指標的操作 -- 錯誤處理 #include "stdafx.h" #include using namespace std; int main(int argc, char* argv[]) { long* pN = NULL; // 指標宣告和初始化 long try1 = 199, try2 = 299; pN = &try1; // 儲存位址於指標 *pN += 2; // 增加值 2 cout << endl << "try1 = " << try1 << " &try1 = " << hex << pN; pN = &try2; // 改為指向 try2 try1 = *pN*3; // try2 乘 3 cout << endl << "try1(十進位) = " << dec << try1 << endl << "try1(十六進位) = " << hex << try1 << endl << " pN = " << hex << pN << endl << " *pN = " << dec << *pN; cout << endl; return 0; }