The Windows platform does not provide a two string manipulation function.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.