首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

字符串赋值和连接有关问题

2012-02-05 
字符串赋值和连接问题这个程序就是拼接两个字符串,但我总觉得不太简便,有没有什么更好的处理方法int_tmain

字符串赋值和连接问题
这个程序就是拼接两个字符串,但我总觉得不太简便,有没有什么更好的处理方法

int   _tmain(int   argc,   _TCHAR*   argv[])
{

TCHAR   szDirectory[MAX_PATH];
::GetCurrentDirectory(sizeof(szDirectory),   szDirectory);

TCHAR   pszPlayer[MAX_PATH];
TCHAR   pszSwf[MAX_PATH];
wcscpy(pszPlayer,   szDirectory);
wcscpy(pszSwf,   szDirectory);

wcscat(pszPlayer,   L "\\FlashPlayer.exe ");
wcscat(pszSwf,   L "\\main\\template.swf ");

::ShellExecute(NULL,   L "open ",   pszPlayer,   pszSwf,   NULL,   SW_SHOWNORMAL);

return   0;
}


[解决办法]
你用string或者CString就简单了。
[解决办法]
wsprintf
[解决办法]
splite
[解决办法]
使用std::string 直接连接就可以了
[解决办法]
int _tmain(int argc, _TCHAR* argv[])
{

TCHAR szDirectory[MAX_PATH];
::GetCurrentDirectory(sizeof(szDirectory), szDirectory);

CString player(szDirectory);
CString swf(szDirectory);

::ShellExecute(NULL, _T( "open "), player+_T( "\\FlashPlayer.exe "), swf+_T( "\\main\\template.swf "), NULL, SW_SHOWNORMAL);

return 0;
}
[解决办法]
strcat不行吗?

热点排行