C6270

warning C6270: missing float argument to <function>: add a float argument 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 floating-point number. This defect can lead to crashes, in addition to potentially incorrect output.

Example

The following code generates this warning:

#include <stdio.h>
#include <string.h>

void f()
{
  char buff [25];
  sprintf(buff,"%s %f","pi:");
}

To correct this warning, pass the missing argument as shown in the following code:

#include <stdio.h>
#include <string.h>

void f()
{
  char buff [25];
  sprintf(buff,"%s %f","pi:",3.1415); 
}

The following sample code uses the safe string manipulation function, sprintf_s, to correct this warning:

#include <stdio.h>
#include <string.h>

void f()
{
  char buff [25];
  sprintf_s( buff, 25,"%s %f", "pi:",3.1415 );
}

See Also

Reference

sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l