C6064

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at C6064.

warning C6064: missing integer argument to <function> corresponding to conversion specifier <number>

This warning indicates that not enough arguments are being provided to match a format string and one of the missing arguments is an integer. This defect can cause incorrect output.

The following code generates this warning because an incorrect number of arguments were used in call to sprintf and the missing argument was an integer:

#include <string.h>  
void f( )  
{  
  char buff[15];  
  char *string="Hello, World";  
  
  sprintf(buff,"%s %d", string);  
}  

To correct this warning, specify missing arguments as shown in the following code:

#include <string.h>  
void f( )  
{  
  char buff[15];  
  char *string = "Hello, World";  
  
  sprintf(buff,"%s %d",string, strlen(string));  
}  

The following code uses safe string manipulation function, sprintf_s to correct this warning:

#include <string.h>  
void f( )  
{  
  char buff[15];  
  char *string="Hello World";  
  
  sprintf_s(buff,sizeof(buff),"%s %d", string, strlen(string));  
}  

sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l

Show: