C Standard library functions: String. h: strchr, implementation of strrchr

Source: Internet
Author: User
/*  Strchr  */  /*  This function is used to locate the first occurrence of a character in a string.  */  /*  If it is found, the absolute address is returned. If it is not found, null is returned.  */  Char * /*  Returns the absolute position of the first occurrence of a string.  */  My_strchr (  Const   Char * SRC,/*  String to be searched  */      Char Ch /*  Characters to be searched  */  ){  While (* SRC! = CH) /*  Test from the first character. If not equal, null is returned.  */  {  If (* Src = '  \ 0 '  )  Return  NULL; SRC ++; /*  Point to the next character  */  }  Return ( Char *) SRC; /*  This is returned only when the first character is the character to be searched.  */  }  /*  Strrchr */  /*  This function returns the position of the last occurrence of a character in the string.  */  /*  Locate: returns the absolute position. Not found: returns NULL  */  Char * My_strrchr (  Const   Char * SRC, /*  String to be searched  */      Char Ch /* Characters to be searched  */  ){  Const   Char * PTR;  For (PTR = NULL; ++ SRC) /*  Match from the first character  */  {  If (* Src = CH) /*  No value can be reassigned once.  */ PTR = SRC;  If (* Src = '  \ 0  ' ) /*  End of arrival  */              Return ( Char * ) PTR;} the girl does not cry (QQ:  191035066 )@ 2012 - 05 -29   16 : 51 : 48 @ Http: //  Www.cnblogs.com/nbsofer 

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.