1:C++下面string、char *、char**的相互转化
string str1="hello 你好";
char *str2=const_cast<char*>(str1.c_str());
char **str3=&str2;
这些是可以的,但是
char **str4;
*str4=const_cast<char*>(str1.c_str());
在使用的时候会提示str4没有定义,由于对于C++不熟悉,暂时不研究。
2:包含lib文件的方法
#pragma comment( lib , "file.lib" )
3:详见拙文CString和char*的相互转换
4:读入文本文件并将它显示到Edit Control
CStdioFile inFile(FileName,CFile::modeRead|CFile::typeText);
CString strLine,strAll;
strAll="";
while (inFile.ReadString(strLine))
{
strAll.AppendFormat("%s\r\n",strLine); //必须加入/r/n才能在Edit Control中显示换行
}
inFile.Close();
m_explanation=strAll;
string str1="hello 你好";
char *str2=const_cast<char*>(str1.c_str());
char **str3=&str2;
这些是可以的,但是
char **str4;
*str4=const_cast<char*>(str1.c_str());
在使用的时候会提示str4没有定义,由于对于C++不熟悉,暂时不研究。
2:包含lib文件的方法
#pragma comment( lib , "file.lib" )
3:详见拙文CString和char*的相互转换
4:读入文本文件并将它显示到Edit Control
CStdioFile inFile(FileName,CFile::modeRead|CFile::typeText);
CString strLine,strAll;
strAll="";
while (inFile.ReadString(strLine))
{
strAll.AppendFormat("%s\r\n",strLine); //必须加入/r/n才能在Edit Control中显示换行
}
inFile.Close();
m_explanation=strAll;

浙公网安备 33010602011771号