I’m using the function ‘strdup’ to insert a char* into a char** and getting the search.c:174:13: warning: assignment makes pointer from integer without a cast [enabled by default] warning.
char** temp;
...
temp = NULL;
...
temp[0] = strdup(tokens[i]);
Where tokens[i] is just a string from the strtok() function.
I don’t think it’s related but I have this warning as well…
search.c:174:5: warning: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration] which is only showing because I have the -ansi flag and I checked that the function was working, I just hate seeing warnings.
Also I apologize if this question was answered; there’s tons of question similar to this one but none of them helped me because from what I can tell my types are matching. (obviously not if I’m getting the warning)
It is related, both have the same cause. You have no prototype for
strdupin scope, so the return type is assumed to beint(in C89/C90; implicit declarations have been removed in C99, but are still widely accepted by default).You need to
#include <string.h>and enable one of the featur test macros that letstrdupbe defined, e.g._XOPEN_SOURCE >= 500or_BSD_SOURCE(and possibly even that will only work without-ansi).