Char: A basic data type that can hold a single character in the Computer programming language (c, C + +, Java, VFP, etc.).
TCHAR: To satisfy Unicode encoding, the extension of Char, i.e. _t ("str"), represents the TCHAR type
C + + supports two strings, the conventional ANSI encoding (using the "package") and the Unicode encoding (using the L "" package), which corresponds to two sets of string string handlers, such as strlen and Wcslen, for handling two string char and TCHAR types, respectively.
WinNT.h header file:
typedef WCHAR TCHAR, *ptchar;
Indicates that TCHAR and WCHAR belong to the same type
Char sza[100]; ANSI String Buffer
WCHAR szw[100]; Unicode String Buffer
Normal Sprintf:all strings are ANSI
sprintf (Sza, "%s", "ANSI Str");
Converts Unicode string to ANSI
sprintf (Sza, "%s", L "Unicode Str");
Normal Swprintf:all strings are Unicode
swprintf (szw,l "% s", L "Unicode Str");
Converts ANSI string to Unicode
swprintf (szw,l "%s", "ANSI Str");
Note: The use of uppercase s and lowercase s
Application instance: Invoking the start MSC program through the system function program
void
Wsus::onbnclickedok ()
{
CString strpath = NULL; Application path String (TCHAR)
char strchar[256]; Application path String (char)
M_CUSTOMEDIT.GETWINDOWTEXTW (strpath); Gets the path stored to the strpath
strpath.replace (_t ("\"), _t ("\\\\")); Replace "\" in strpath with "\", note the translator
//sprintf (Strchar, "%s", "Mmc.exe", strpath); TCHAR convert char type
sprintf (strchar, "mmc.exe \%s\" ", strpath); TCHAR converts char type
MessageBox (strpath, _t ("title"));
System (STRCHAR); System function calls start MSC program
//winexec ((LPCSTR) _bstr_t (strpath), sw_show); Calling EXE program
}