Recently, this function is used to construct a binary tree based on the forward and middle orders, but this function is not good because strchr returns a character in the string.First timeIf there are repeated characters, it will be white blind. SoThe premise is that there are no repeated elements in the binary tree..
Header file: # include <cstring> (C ++) or # include <string. h> (c)
Function: locate the first occurrence of character C in string S.
Note: return the pointer at the first occurrence of C. If C does not exist in S, return null.
C ++Program:
# include <iostream> </P> <p> # include <cstring> </P> <p> using namespace STD; </P> <p> int main () </P> <p >{</P> <p> char STR [6] = {'I ', 'l', 'O', 'V', 'E', 'U'}; </P> <p> char C; </P> <p> while (CIN> C) <br/>{</P> <p> char * TMP = strchr (STR, C ); // returns the pointer of 'v' in STR </P> <p> If (TMP! = NULL) </P> <p> cout <* TMP <Endl; </P> <p> else </P> <p> cout <"null" <Endl; </P> <p >}</P> <p> return 0; </P> <p >}</P> <p>