Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
C6303
Collapse the table of content
Expand the table of content

C6303

warning C6303: format string mismatch: wide character string passed as parameter <number> when character string is required in call to <function>

This warning indicates that the format string specifies that a character string is required. However, a wide character string is being passed. This defect is likely to cause a crash or corruption of some form.

The following sample code generates this warning:

#include <stdio.h>

void f()
{
  wchar_t buff[5] = L"hi";

  printf("%s", buff);
}

To correct this warning, use %ls as shown in the following sample code:

#include <stdio.h>

void f()
{
  wchar_t buff[5] = L"hi";

  printf("%ls", buff);
}

The following sample code uses safe string manipulation function printf_s to correct this warning:

#include <stdio.h>

void f()
{
  wchar_t buff[5] = L"hi";

  printf_s("%ls",buff);
}
Show:
© 2015 Microsoft