Dela via


C6063

warning C6063: missing string argument to <function> corresponding to conversion specifier <number>

This warning indicates that not enough arguments are being provided to match a format string; at least one of the missing arguments is a string. This defect can cause crashes and buffer overflows (if the called function is of the sprintf family), as well as potentially incorrect output.

Example

The following code generates this warning:

#include <string.h>
void f( )
{
  char buff[15];
  sprintf(buff, "%s %s", "Hello, World!");
}

To correct this warning, provide additional arguments as shown in the following code:

#include <string.h>
void f( )
{
  char buff[15];
  sprintf(buff, "%s %s ", "Hello","World");
}

The following code corrects this warning using safe string manipulation function:

#include <string.h>
void f( )
{
  char buff[15];
  sprintf_s( buff, sizeof(buff),"%s", "Hello, World!" );
}

See Also

Reference

sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l