刚开始学习C++笔记,请绕过
MessageBox输出变量(实为const),变量赋值采用数组形式逐个赋值
wchar_t buffer[4]={};
string str="fdsf";
for(int i=0; i< 3; i++)
{
buffer[i]=str[i];
}
MessageBox(NULL, buffer, L"caption", 0);
string str="fdsf";
for(int i=0; i< 3; i++)
{
buffer[i]=str[i];
}
MessageBox(NULL, buffer, L"caption", 0);
数字转字符串
#include <string>
#include <sstream>
string num2str(double i)
{
stringstream ss;
ss<<i;
return ss.str();
}
#include <sstream>
string num2str(double i)
{
stringstream ss;
ss<<i;
return ss.str();
}
数字转宽字符串
#include <string>
#include <sstream>
#include <sstream>
string str;
wchar_t buffer[10]={};
void num2wchar_t(double i)
{
stringstream ss;
ss<<i;
str = ss.str();
void num2wchar_t(double i)
{
stringstream ss;
ss<<i;
str = ss.str();
for(int i=0; i< str.length(); i++)
{
buffer[i]=str[i];
}
}
{
buffer[i]=str[i];
}
}
字符串 转数字
int str2num(string s)
{
int num;
stringstream ss(s);
ss>>num;
return num;
}
{
int num;
stringstream ss(s);
ss>>num;
return num;
}