#include "stdafx.h" #include <iostream> #include <windows.h> #include <memory> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int len = 128; shared_ptr<char> ptr(new char[len]); //得到指针的原始地址 char* addr = ptr.get(); memset(addr, 0, len); strcpy_s(addr, len, "fasfwefew"); cout << "string :" << addr << endl; shared_ptr<int> ptr1(new int); *ptr1 = 100; cout << *ptr1.get() << " " << *ptr1 << endl; system("pause"); return 0; }