Having a weird problem
sprintf(tmp, "\"%s\"", filename);
I expect the output to be
"filename"
but instead I get
\"filename\"
What is going on here?
=============================
extern "C" void __export __pascal MyFunc(LPTSTR m_avi, LPTSTR m_mpg)
{
int frameRate = 20;
char szAVI[MAX_PATH], szMPG[MAX_PATH];
#ifdef UNICODE
wcstombs(szAVI, m_avi, _tcslen(m_avi) + 1);
wcstombs(szMPG, m_mpg, _tcslen(m_mpg) + 1);
#else
strcpy(szAVI, m_avi);
strcpy(szMPG, m_mpg);
#endif
//Call to ffmpeg.exe
char cmdline[1000] = "ffmpeg ", tmp[50];
//Overwrite without asking
strcat(cmdline, "-y ");
//Input file
sprintf(tmp, "-i \"%s\" ", szAVI);
strcat(cmdline, tmp);
//Lock output at 20 frames per second
sprintf(tmp, "-r %i ", frameRate);
strcat(cmdline, tmp);
//Output file
sprintf(tmp, "\"%s\"", szMPG);
strcat(cmdline, tmp);
WinExec(cmdline, SW_HIDE);
}
Since the code you’ve shown doesn’t actually produce any output, I suspect the “output” you’re talking about is coming from your debugger, where you’re attempting to inspect the value of your array before you call
WinExec.Debuggers often display the values of variables using the syntax of the language being debugged. The debugger in this case is showing you that the string variable contains quotation marks. Since quotation marks are special in C++, the debugger also displays backslashes to indicate that the quotation marks are part of the string’s contents, not denoting the start or end of a string value.
If you’re seeing backslashes in the debugger, then everything’s fine. If you’re seeing backslashes printed out or displayed somewhere in your program, then you need to go look at that code since the code here in the question doesn’t display anything.