Internationalization and localization tools


String Format Function

int _cprintf(const char *format [, argument] ... );

int _cwprintf(const wchar_t *format [, argument] ...);

int _tcprintf(const TCHAR *format [, argument] ...);

Internationalization (I18n) Function Overview

The _cprintf function prints a formatted string directly to the console, returning the number of single-byte characters printed. Each optional argument is converted according to the specification in format.

_cwprintf is the wide-character version of _cprintf. Its argument is a wide-character string and it returns the number of wide-characters printed.

_tcprintf is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _cprintf or _cwprintf.

I18n Issues

Use the appropriate version of the function as required for Windows platform support, noting the following:

These functions should not be used for strings that are locale-dependent. _cprintf is not dependent on locale, and so numeric values will not be formatted correctly. As for _cwprintf, although it does print Unicode characters and formats according to locale, it uses the current console locale, rather than the current user's locale.

See String Formatting in C and C++ for a discussion on locale-sensitive formatting in internationalized applications.

Recommended Platform Replacements

String Format Functions

 

Lingoport internationalization and localization services and software