参考书目:C/C++规范设计简明教程, P194
//测试常量字符串
#define _CRT_SECURE_NO_WARNINGS
#include <iostream> //C++语言库,用于使用cout
#include <stdio.h> //C语言库,用于使用printf
#include <math.h>
using namespace std;
int main()
{
cout << "Hello World!\n";
printf("字符串“china”的地址是:%p\n", &("china"));
cout<<"字符串“china”的地址是"<<(int*)( &("china")) << endl;
printf("字符串“I love you ”的地址是:%p\n", &("I love you "));
getchar();
}
输出结果如下: