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

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.

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 );
}
Show:
© 2015 Microsoft