system function C string implementation (one-by-one): STRCHR

Source: Internet
Author: User

Character Lookup function strchr

Char *mystrchr (const char *STR, const char c) {char *p = null;for (char*newp = str; *NEWP! = ' + '; newp++) {if (*newp==c) {p = newp;//A one-find break;}} return p;} Char *MYSTRCHRDG (const char *STR, const char c) {if (*str!= '} ') {return NULL;} Else{if (*str==c) {return str;//returns pointer}mystrchrdg (++STR, c);//loop area terminates}}//mystrchrvoid main () {char *pstr1 = MYSTRCHR ("Zrf Is Rocket ", ' Z '); char *pstr2 = <span style=" font-family:arial, Helvetica, Sans-serif; " >mystrchrdg</span> ("ZRF is Rocket", ' A ');p rintf ("pstr2=%s\n", PSTR2); if (pstr1 = = NULL) {printf ("Can not find") ;} else{printf ("Can  find  %p   exists this character:%c\n", PSTR1, *PSTR1);} System ("Pause");}


Copyright NOTICE: This article is for bloggers original article, welcome to point out the code is bad, and put forward the Code optimization scheme. Welcome guidance, Night code, desperately struggling to update in ...

system function C string implementation (one-by-one): STRCHR

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.