views:

203

answers:

3

I can only find references for small c. I assume that the capital C is for Unicode, but I'm not sure. For lower numbers, both output the same character.

+4  A: 

From MSDN

%c

When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character.

%C

When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character.

Ahmed Said
+4  A: 

From MSDN:

%c

type: int or wint_t

When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character.

%C

type: int or wint_t

When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character.

more about format specifiers here

Indeera
+3  A: 

Note that %C isn't standard. Standard conversion for characters are:

  • %c is used for a int. printf output it as it if was an unsigned char. wprintf output the result of the convertion to a wchar_t by btowc.
  • %lc is used for a wint_t. printf output the result of the conversion to a multibyte string by wcrtomb. wprintf output it as if it was a wchar_t.
AProgrammer
Which also implies that the Microsoft behaviour for %c in the *w*printf functinos is also non-compliant. From MSDN: "The types C, n, p, and S, and the behavior of c and s with printf functions, are Microsoft extensions and are not ANSI compatible."
Charles Bailey
The standard defines a behavior for n and p which seems to match the one described in the MSDN link above (which doesn't mention n and p as extension BTW). And I assume that the use of printf instead of wprintf is a typo. Looking at that page, I see another Microsoft extension: the use of h as modifier with c and s which gives them back their standard behavior.
AProgrammer