Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
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]);
}