How to resolve " invalid operands of types 'const char [ ]' and 'const char*' to binary 'operator+' "

StackOverflow https://stackoverflow.com/questions/21957516

  •  15-10-2022
  •  | 
  •  

Question

I use Qt Creator and this code :

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

generate this issue on line 3 :

invalid operands of types 'const char [60]' and 'const char*' to binary 'operator+'

How to solve it?

Était-ce utile?

La solution

You'll want something like:

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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top