string-Related header file resolution (__c++ + +)

Source: Internet
Author: User
string-Related header file resolution (C + +)


1. The following is a familiar header file
String functions provided by the #include <string> C + + standard library
#include <string.h> C standard library
#include <cstring> C + + C + + Enhancements to standard C string processing functions
string is defined as a string class, needless to say, but what String.h and CString have.
*
 * * is the C + + version of the Standard C Library header @c string.h, * and its
 contents are (mostly) the SAM E as this header, but are all
 * contained in the namespace @c std (except for names which are defined
 * as macros In C).
 */
That is, the contents of these two files (almost) are the same (except for the names of some of the macros).
Why is that almost the same? is because there is still a difference, in c++11, this function declares:
void *memchr (const void*, int, size_t)//In C * *
Replaced by the following two statements:
void *memchr (void *, int, size_t)/* in C + +
/const void *MEMCHR (const void *, int, size_t)/* in C + + *
In fact, the implementation of 3 functions is the same.

2. In some systems (unix/linux etc.) There is also a header file Strings.h
Strings.h derives from Unix-derived BSD systems, which were later normalized by POSIX, but many of these functions are identified as lagacy (Legacy), most of which can be replaced by other functions:
int    bcmp (const void *, const void *, size_t),/* LEGACY, memcmp
/void   bcopy (const void *, void *, size_t ); /* LEGACY, memcpy, memmove
/void   bzero (void *, size_t),//* LEGACY, and
[memset]    /int ffs (int);
Char  *index (const char *, int);/* LEGACY, STRCHR *  /char *rindex (const char *, int);/* LEGACY, and then Str RCHR *    /int strcasecmp (const char *, const char *);
int    strncasecmp (const char *, const char *, size_t);
This header file is not used frequently (not in the Windows environment).

3. To say the end of the document, there is still a question to say
<> the difference between a referenced header file and a header file that is referenced: In fact, the search path is different.
The search path for the header file referenced by <> is the system library path;
The search path for the header file referenced is the current path first, and if the current path does not have the file, the system path is searched.


Reference:
The difference between string.h and strings.h

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.