_sntprintf(szCmd, szCmdSize, szScanner ,
I am trying to add a space before szScanner
in vb you do it using the ff. " " & szScanner & " " bu I do not know it in c++, i have tried to do it like that but it displays an error message "'&' illegal,...."
and I also tried to use the + and it does not work too...
Well, the _sntprintf() function is NOT C++. It is C. In C++ is very similar to VB:
1 2 3 4 5 6
//Use std::string if ANSI, or std::wstring if UINICODE. This typedef quickly take care of both cases.
//To use this, #include <string>.
typedef std::basic_string<TCHAR> tstring;
tstring myString = _T(" "); //The needed space.
myString += szScanner; //And that's it!
If you would like to continue using C, I suppose that you have already allocated the buffer pointed to by szCmd, taking into account the proper char size and such? If yes, then the call should look like this:
1. The hungarian-styled variable name "szCmdSize" is incorrect. Since it represents a count, it should be cCmdSize. I'll even take dwCmdSize, but never szCmdSize because it is not a null terminated string, and "sz" is reserved for null terminated strings only.
2. The _T(" %s") argument is the format string and has the needed space right before the string placeholder (the %s part).