sprintf、swprintf
are for single-byte/double-byte characters respectively. wsprintf can under-form single-byte/double-byte characters according to different predefined indicators. Comparing wsprintf and swprintflinux sprintf header file, although these two functions are the same for users, the latter is declared in Winbase.h; the former is declared in stdio.h, stdlib.h stated in the document. For wsprintf, the compiler will detect the macros you define during the compilation process, and then convert the functions starting with _tcs in the TCHAR.H file into the corresponding functions starting with str or wcs. If you want to build a program that uses the UNICODE character set, you can define the _UNICODE macro. If you want to build a single-byte program, you do not need to define any macroslinux sprintf header file. Single-byte character programs are the default (this is the case for WIN32, and the default for WINCE is unicode character programs).
is used the same as sprintf, #include
intmain(){
wchar_ta[123];
swprintf(a,L"%f",123.456);wprintf(a);}
Note that L must be added to the second parameter to specify it as a wide character string
wsprintf is windowsapi, which does not support floating-point output to LINUX virtual machines. swprintf is a c library function. Its usage is the same as sprintf (the format is the same), but it is for wide characters.
The above is the detailed content of What is the default format for single-byte/double-byte characters?. For more information, please follow other related articles on the PHP Chinese website!