Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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

Community Additions

ADD
Show:
© 2015 Microsoft