I'm coming from a C# background and my C++ is very rusty so please bear with me.
The following function definition accepts pointers (LPTSTR) to strings representing an input filename (szIn) and output filename (szOut). Here is the function prototype:
ConvertFile(LPTSTR szIn, LPTSTR szOut);
Currently the function is executed from within some UI code, here's an example of how the output filename is obtained from the pointer szOutput
:
TCHAR szOutput[255]; // output filename
if (g_szFilename[0] != 0)
{
SetDlgItemText(hMainDlg, IDC_EDIT_INPUT, g_szFilename);
_tcscpy(szOutput, g_szFilename);
TCHAR * szExt = _tcsrchr(szOutput, '.');
if (szExt != NULL) *szExt = 0;
_tcscat(szOutput, _T(".png"));
}
I want to do something along these lines:
TCHAR inputFilename[256];
TCHAR outputFilename[256];
inputFilename += "somefile.txt";
outputFilename += "someotherfile.txt";
char *inputPtr;
char *outputPtr;
inputPtr = inputFilename;
outputPtr = outputFilename;
ConvertFile(inputPtr, outputPtr);
Is this the correct syntax for Microsoft's flavor of C++ in Visual Studio 2008?
No, you cannot concatenate a string like that. You are trying to append a
const char[]
onto the end of another array... which won't even compile. You need to use _tcscat() or (better yet as you have added the C++ tag),std::basic_string<TCHAR>
.