C and pointer Chapter 6 first question

Source: Internet
Author: User
/*  * C and pointer. In chapter 6, the first question is to find the characters that appear in a specific character set. Basic Idea: match the first character of any character in the Chars string in source.  */  # Include <Stdio. h> # Include <Stdlib. h> Char   Const * Find_char ( Char   Const * Source, Char   Const * Charz ){  Int A = 0 ;  Char   Const * Src = Source;  Char   String = * SRC;  While ( String ! = '  \ 0  '  ){  Char   Const * Chars =Charz;  For (; * Chars! = '  \ 0  '  ;){  If (* Chars ++! = String ) Continue  ;  Else  { = 1  ;  Break ;}}  If (A = 1  ){  Return  SRC ;}  Else  {  String = * ++ SRC ;}}  Return  NULL ;}  Int Main ( Void  ){ Char Source [ 100  ];  Char Chars [ 100  ];  Char   Const * SRC; printf (  "  Enter a source string: \ n  "  ); Gets (source );  While ( 1 ) {Printf (  "  Enter a search string: \ n  "  ); Gets (chars); SRC = Find_char (source, chars );  If (Src = Null) {printf (  "  Matching failed !! : \ N  "  );  Continue  ;} Printf (  " Matched !! : \ N  "  ); Printf (  "  % C  " ,* SRC );  While (* ++ SRC! = '  \ 0  '  ) Printf (  "  % C  " ,* SRC); printf ( "  \ N  "  );}  Return   0  ;} 

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.