how to correct this warning?
-
Quote:
warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char **’
-
The message is telling you how to correct it; you must use a
char*
parameter for the%s
format type. See http://msdn.microsoft.com/en-us/library/56e442dc.aspx[^]. -
Quote:
warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char **’
The format
%s
is used to output a null terminated string. The variable it expects is achar*
. I can think of 2 possibilities. Since you haven't posted any relevant code, I'm only guessing here. First guess is that you're trying to print a string and are using an extra&
character -char string[20];
printf("%s", &string); // The & is not needed here.Second guess is that you've received a
char**
as a function argument and trying to print it.void fun(char** arg)
{
printf("%s", *arg); // * is needed here.
}It would be best if you can post the relevant code.
«_Superman_» _I love work. It gives me something to do between weekends.
_Microsoft MVP (Visual C++) (October 2009 - September 2013)