다음을 통해 공유


C6271

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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

sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l