The difference between STRSTR and STRCHR

Source: Internet
Author: User
Tags function prototype
In C, the STRCHR and STRSTR functions are included in the <string.h> header file, which is to include the <string.h> header file in front of the program to invoke them, that is, to write this statement: #include < String.h>
STRCHR function prototype: char * STRCHR (char * str, int ch); The function is to find out the position of the character ch for the first time in string str, and find a pointer that returns the character position ( That is, returns the position of the character's address in the string, and returns an empty pointer (or null) if it is not found.
strstr function Prototype: char * STRSTR (char * str1,char * str2); The function is to find out the position of the string str1 for the first time in the string str2 (that is, the string SR1 contains the string str2). Finds a pointer that returns the position of the string (that is, the position of the address that returns the string str2 in the string str1), and returns a null pointer (that is, null) if it is not found.

one is to find the position of one character in a string, and the other to find the position of a string within another string.
These are all in the last of C language books, you have to learn to read more books, to solve their own problems. Learn to program is to have patience, learn a long time will understand.

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.