Hello!
Im trying to make work this function that works like the real strdup() function but i get
"error: invalid conversion from `void*' to `char*'" on the return; line.
Code:#include <iostream> using namespace std; char * strdup(const char * s) { size_t len = 1+strlen(s); char *p = (char*)malloc(len); return p ? memcpy(p, s, len) : NULL; // error here } int main(int nArg, char* pszArgs[]) { char buf[6] = "hello"; cout << strdup(buf) << endl; }