Convert Between Pointers and Numbers with reinterpret_cast
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
int main(void)
{
char* pStr = "A";
int* pInt = reinterpret_cast<int*>(pStr);
Console::WriteLine("As string: ");
Console::WriteLine(pStr);
Console::WriteLine("As integer: ");
Console::WriteLine(*pInt);
return 0;
}
Related examples in the same category