Search code examples
cprintffilestream

Fprintf VS _ftprintf


both have almost same input parameters:

int _ftprintf( FILE *stream, const _tchar *format [, argument ]...)

int fprintf(FILE *stream, const char *format, ...)

What is the difference between the two format agruments? When should I use each?


Solution

  • _tprintf and _ftprintf are to be used with TCHAR format strings. TCHAR is just a macro, which unwraps into either char or wchar_t, depending on whether is the _UNICODE macro defined.

    So, basically, if you don't have _UNICODE defined, _ftprintf will be equivalent to fprintf, otherwise it will be equivalent to fwprintf.