Share via


C6274

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 C6274: non-character passed as parameter <number> when character is required in call to <function>

This warning indicates that the format string specifies that a character is required (for example, a %c or %C specification) but a non-integer such as a float, string, or struct is being passed. This defect is likely to cause incorrect output.

Example

The following code generates this warning:

#include <stdio.h>  
#include <string.h>  
  
void f(char str[])  
{  
   char buff[5];  
  
   sprintf(buff,"%c",str);  
}  

To correct this warning, use the following code:

#include <stdio.h>  
#include <string.h>  
  
void f(char str[])  
{  
   char buff[5];  
  
   sprintf(buff,"%c",str[0]);  
}  

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

#include <stdio.h>  
#include <string.h>  
  
void f(char str[])  
{  
   char buff[5];  
  
   sprintf_s(buff,5,"%c", str[0]);  
}