2014-02-22 37 views
0

我使用Qt Creator和验证码:如何解决 “类型 '为const char []' 和 '为const char *' 的无效操作数为二进制 '运营商+'”

string execpath = ""; 
execpath += (QCoreApplication::applicationDirPath()).toStdString(); 
WinExec("ffmpeg -f dshow -t 32 -i audio=\"virtual-audio-capturer\" -y "+(execpath.c_str())+"\\sound.mp3", SW_HIDE); // Loopback captured in sound.mp3 

第3行产生这个问题:

类型的无效操作数 '为const char [60]' 和 '为const char *' 来 二进制 '运营商+'

如何解决呢?

+4

不能与+运营商加在一起C风格的字符串第一 – Brian

+1

在连接字符串和*然后*调用'.c_str('级联'的std :: string' – Brian

回答

3

你会想是这样的:)在

execpath += (QCoreApplication::applicationDirPath()).toStdString(); 
std::string cmd = "ffmpeg -f dshow -t 32 -i audio=\"virtual-audio-capturer\" -y " 
WinExec((cmd +execpath +"\\sound.mp3").c_str(), SW_HIDE); 
+0

execpath的是,我在我的代码中使用了大量的变量,但我想你是对的 – AmirH

+0

这工作: 的WinExec(字符串(“ffmpeg的-f -t用于dshow 32 -i音频= \” virtual-audio-capturer \“-y”+ execpath +“\\ sound.mp3”)。c_str(),SW_HIDE); //在sound.mp3中捕获Loopback – AmirH

相关问题