C++ 如何解决;类型为';常量字符[]和#x27;和';常量字符*';到二进制';操作员+'&引用;
我使用Qt Creator和以下代码:C++ 如何解决;类型为';常量字符[]和#x27;和';常量字符*';到二进制';操作员+'&引用;,c++,qt,c-str,C++,Qt,C Str,我使用Qt Creator和以下代码: 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
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*”的操作数无效
二进制“运算符+”
如何解决它?您将需要类似以下内容:
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);
您将需要以下内容:
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);
您将需要以下内容:
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);
您将需要以下内容:
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);
不能将C样式字符串与+运算符相加,也不能先将字符串合并,然后在连接的
std::string
上调用.C_str()
,不能将C样式字符串与+运算符相加,也不能先将字符串合并,然后调用.C_str()
在连接的std::string
上,不能将C样式字符串与+运算符相加或先将字符串合并,然后在连接的std::string上调用.C_str()
不能将C样式字符串与+运算符相加或先将字符串合并,然后调用.C_str()
在连接的std::string上
execpath是一个变量,我在我的代码中使用了很多,但我想你是对的这是有效的:WinExec(string(“ffmpeg-f dshow-t32-I audio=\“virtual audio capturer\”-y“+execpath+“\\sound.mp3”)。c_str(),SW_HIDE);/在sound.mp3execpath中捕获的环回是一个变量,我在代码中经常使用它,但我想你是对的这是正确的:WinExec(string(“ffmpeg-f dshow-t 32-I audio=\“virtual audio capturer\”-y“+execpath+“\\sound.mp3”).c_str(),SW_HIDE);//在sound.mp3execpath中捕获的环回是一个变量,我在代码中经常使用它,但我想你是对的这是正确的:WinExec(string(“ffmpeg-f dshow-t 32-I audio=\“virtual audio capturer\”-y“+execpath+“\\sound.mp3”).c_str(),SW_HIDE);//在sound.mp3execpath中捕获的环回是一个变量,我在代码中经常使用它,但我想你是对的这是正确的:WinExec(string(“ffmpeg-f dshow-t 32-I audio=\“virtual audio capturer\”-y“+execpath+“\\sound.mp3”).c_str(),SW_HIDE);//在sound.mp3中捕获的环回