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.
Example
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);
}