MFC中CString数据传递问题
请问怎样把CEDIT控件中获得的CString型数据传递给类成员变量charst[500];另请举一些CString型数据与其他类型转换的实例...
请问怎样把CEDIT控件中获得的CString型数据传递给类成员变量
char st[500];
另请举一些CString型数据与其他类型转换的实例 展开
char st[500];
另请举一些CString型数据与其他类型转换的实例 展开
2个回答
展开全部
UpdateData(TRUE)
//比如CEDIT 控件连接的渗铅变量叫m_strEditString;
if (m_strEditString.GetLength()>=500)
{
MessageBox(_T("长度不够"_,_T(""),MB_ICONSTOP)//ERROR
}
else
{
strcpy(st,m_strEditString.GetBuffer(0));
}
//以下是转丛差好换
1、CString::GetBuffer(0);//取得CString的char*
2、int intv=atoi(CString::GetBuffer(0));//CString to Int
3、float floatv=(float)atof(CString::GetBuffer(0));//CString to float
4、long longvv=atol(CString::GetBuffer(0));//CString to Long
5、double doublev=atof(CString::GetBuffer(0));//CString to Double
6、CString::Format(_T("庆型%d,%f,%ld,%lf,%c,%s"),int,float,long,double,char,char*)//各类型到CString
//比如CEDIT 控件连接的渗铅变量叫m_strEditString;
if (m_strEditString.GetLength()>=500)
{
MessageBox(_T("长度不够"_,_T(""),MB_ICONSTOP)//ERROR
}
else
{
strcpy(st,m_strEditString.GetBuffer(0));
}
//以下是转丛差好换
1、CString::GetBuffer(0);//取得CString的char*
2、int intv=atoi(CString::GetBuffer(0));//CString to Int
3、float floatv=(float)atof(CString::GetBuffer(0));//CString to float
4、long longvv=atol(CString::GetBuffer(0));//CString to Long
5、double doublev=atof(CString::GetBuffer(0));//CString to Double
6、CString::Format(_T("庆型%d,%f,%ld,%lf,%c,%s"),int,float,long,double,char,char*)//各类型到CString
展开全部
CString csText;
strcpy(st, csText.GetBuffer(0) );
转换整型:宴备int n = atoi( csText.GetBuffer(0) );
long l = atol( csText.GetBuffer(0) );
double d = atof( csText.GetBuffer(0) );
csText.Format( "%d", n );
其旦信它晌迟毁同理。
strcpy(st, csText.GetBuffer(0) );
转换整型:宴备int n = atoi( csText.GetBuffer(0) );
long l = atol( csText.GetBuffer(0) );
double d = atof( csText.GetBuffer(0) );
csText.Format( "%d", n );
其旦信它晌迟毁同理。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询