C6273
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 6273 - non-integer passed as parameter <number> when integer is required in call to <function>: if a pointer value is being passed, %p should be used
This warning indicates that the format string specifies an integer, for example, a %d
, length or precedence specification for printf
but a non-integer such as a float
, string, or struct
is being passed as a parameter. This defect is likely to result in incorrect output.
Example
The following code generates this warning because an integer is required instead of a float
to sprintf
function:
#include <stdio.h>
#include <string.h>
void f_defective()
{
char buff[50];
float f=1.5;
sprintf(buff, "%d",f);
}
The following code uses an integer cast to correct this warning:
#include <stdio.h>
#include <string.h>
void f_corrected()
{
char buff[50];
float f=1.5;
sprintf(buff,"%d",(int)f);
}
The following code uses safe string manipulation function, sprintf_s
, to correct this warning:
#include <stdio.h>
#include <string.h>
void f_safe()
{
char buff[50];
float f=1.5;
sprintf_s(buff,50,"%d",(int)f);
}
This warning is not applicable on Windows 9x and Windows NT version 4 because %p is not supported on these platforms.