Bagikan melalui


C6271

warning C6271: extra argument passed to <function>: parameter <number> is not used by the format string

This warning indicates that additional arguments are being provided beyond those specified by the format string. By itself, this defect will not have any visible effect although it indicates that the programmer's intent is not reflected in the code.

Example

The following sample code generates this warning:

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

void f()
{
   char buff[5];

   sprintf(buff,"%d",1,2); 
}

To correct this warning, use the following sample code:

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

void f()
{
   char buff[5];

   sprintf(buff,"%d, %d",1,2);
}

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

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

void f()
{
   char buff[5];

   sprintf_s( buff, 5,"%s %d", 1,2 ); //safe version
}

See Also

Reference

sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l