1 Function Type*Function Name (form parameter table)//A pointer function is a function that returns a pointer address.
2 {Function body}
After the function is executed, you can bring back a value to the main function. This value can be of the standard type or different types of pointer data. Then, you can use these pointers to indirectly access the relevant data.
For example, the strchr () function is used to search for a character in a string. If a character is found, the address of the character is returned. Otherwise, a null pointer is returned.
1 # Include < Stdio. h >
2
3 Char * Strchr ( Char * STR, Char Ch)
4 {
5 While ( * Str ! = Ch && * Str ! = ' \ 0 ' )
6 {
7 Str ++ ;
8 }
9
10 Return STR;
11 }
12
13 Int Main ()
14 {
15 Char STR [] = " Liang Yan " ;
16 Char * P, ch;
17
18 Printf ( " Please input CH: " );
19 Scanf ( " % C " , & Ch );
20
21 P = Strchr (STR, CH );
22
23 If (* P)
24 {
25 Printf ( " Output The first STR address in octal format: % O \ n " , STR );
26 Printf ( " Character: % C \ t character % C address in string STR: % O \ n " , Ch, ch, P );
27 Printf ( " Position of the character in the string: % d \ n " , P - Str );
28 }
29 Else
30 Printf ( " Not found! \ N " );
31
32 Return 0 ;
33 }