demo_type_cast_4_reinterpret_cast_1.cpp

来自「对于一个初涉VC++的人来书」· C++ 代码 · 共 22 行

CPP
22
字号

//**********************************************
// reinterpret_cast操作符进行指针之间类型转换
//**********************************************

# include <iostream.h>
# include <string.h>
# include <malloc.h>

int main()
{
//	char* cp=(char *)malloc(100);
	char* cp=reinterpret_cast<char *>(malloc(100));

	strcpy(cp,"Hello, Guys!");
	cout<<cp<<endl;

	free(cp);

	return 0;
}

⌨️ 快捷键说明

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