When looking at some open source code, we often see some string manipulation functions, which are available under the Linux platform, but MS is not provided on the Windows platform. Therefore, the software must be implemented by itself. Common Library functions are:
Obtains a copy of the current character, freeing the memory externally. Char *strdup (const char *src) { int len; Char *dst; len = strlen (src) + 1; if (DST = (char *) malloc (len)) = = null) return (null); strcpy (DST, SRC); return (DST);} Set environment variable int setenv (const char *name, const char *value, int overwrite) { char *cp; int ret; if (overwrite = = 0) { if (getenv (name)) return 0; } CP = (char *) malloc (strlen (name) + strlen (value) + 2); if (cp = = NULL) return-1; sprintf (CP, "%s=%s", name, value); RET = PUTENV (CP); #ifdef WIN32 free (CP); #endif return ret;}
The Windows platform does not provide a two string manipulation function.