#include<iostream> #include<string> #define MAX_NUX 100//宏变量定义,注意:不能加冒号 using namespace std; int main() { cout << MAX_NUX << endl; const int MAX_NUM2 = 200;//const常量定义 cout << MAX_NUM2 << endl; return 0; }
#include<iostream> using namespace std; int main() { //二维数组数组名 int arr[2][3] = { {1,2,3}, {4,5,6} }; cout << "二维数组大小: " << sizeof(arr) << endl; cout << "二维数组一行大小: " << sizeof(arr[0]) << endl; cout << "二维数组元素大小: " << sizeof(arr[0][0]) << endl; //地址 cout << "二维数组首地址:" << arr << endl; cout << "二维数组第一行地址:" << arr[0] << endl; cout << "二维数组第二行地址:" << arr[1] << endl; cout << "二维数组第一个元素地址:" << &arr[0][0] << endl;//也就是二维数组首地址 cout << "二维数组第二个元素地址:" << &arr[0][1] << endl; system("pause"); return 0; }
#include<iostream> using namespace std; int main() { //定义 int a = 10; int* p = &a; //使用 cout << p << endl;//输出地址 cout << *p << endl;//解引用 system("pause"); return 0; }