学习笔记:测试常量字符串的地址

参考书目: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();
}

输出结果如下:

发布了34 篇原创文章 · 获赞 1 · 访问量 756

猜你喜欢

转载自blog.csdn.net/qq_41708281/article/details/104131206