You are using Dev-C ++, but strdup is not part of the C or C ++ standard, it is a POSIX function. You need to determine the correct (according to your IDE documentation) preprocessor characters so that strdup is declared a header file ... it is necessary that the header file does not pollute the namespace when included in the corresponding C or C ++ source files.
For a simple portable alternative, consider
char* mystrdup(const char* s) { char* p = malloc(strlen(s)+1); if (p) strcpy(p, s); return p; }
Or, if you know that strdup is actually in the library, you can copy its declaration from string.h to your own source file or header ... or use a simpler declaration from the man page:
char *strdup(const char *s);
source share