Creative Code

pointer3.cpp(reinterpret_cast) 본문

C++ Programming

pointer3.cpp(reinterpret_cast)

빛하루 2023. 9. 8. 16:55
#include <stdio.h>



int main(void)

{

	int a = 0x12345678;

	char *p;

	//p = (char*) &a;

	p = reinterpret_cast<char *>(&a);  //강제 형 변환 static_cast가 안될 때

	printf("*p : 0x%x\n",*p);

	return 0;

}

'C++ Programming' 카테고리의 다른 글

shape(dynamic_cast)  (0) 2023.09.08
string4(const_cast)  (0) 2023.09.08
genderRatio.cpp(static_cast)  (0) 2023.09.08
safeArray4(try-throw-catch)  (0) 2023.09.08
swap2(template 함수)  (0) 2023.09.08