C6271

 

For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see C6271 on docs.microsoft.com. 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.

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  
}  

sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l

Show: