字串與字元陣列的轉換
只是單純的做個筆記....
#include "stdafx.h"
#include <iostream>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
// std string converts to char array
std::string szBuff_1 = "buff 1";
char acBuff_1[32];
::memset(acBuff_1, 0, sizeof(acBuff_1));
::strcpy(acBuff_1,szBuff_1.c_str());
std::cout << acBuff_1 << std::endl;
// char array converts to std string
std::string szBuff_2 = "";
char acBuff_2[32];
::memset(acBuff_1, 0, sizeof(acBuff_1));
::strcpy(acBuff_2, "buff 2");
szBuff_2 = static_cast<std::string>(acBuff_2);
std::cout << szBuff_2 << std::endl;
}