字符串数组中查找固定字符串

 1 /*
 2 *在字符串数组中查找固定字符串
 3 */
 4 #include<stdio.h>
 5 #include<string.h>
 6 #define TRUE 1
 7 #define FALSE 0
 8 
 9 int find_char(char **strings, char *value)
10 {
11     char *string;     //字符串循环变量
12     char *parValue;   //和value一样,只是易于回归
13     while ((string = *strings++)!= NULL)
14     {
15         parValue = value;
16         while (*string != '' && *parValue != '')  //两个字符串均未结束
17         {
18             if ((*string++ == *parValue++) && (*string == '' || *parValue == ''))   //两个字符串一致并且字符串中有一方结束
19             {
20                 return TRUE;
21             }
22         }
23     }
24     return FALSE;
25 }
26 int main()
27 {
28     char *str[10] = { "Hello", "world", "love" };
29     printf("%d", find_char(str, "love"));
30     return 0;
31 }
其中遇到的知识点:
(1)二级指针数组传参(进一步加深理解)
(2)在程序调试过程中,遇到这样一个问题:
第一次调试,进入find_char函数内部:

执行(*strings++)后,执行如下:

以后只要上述循环进行,均会发生变化;这个字符串指针和字符串数组与自己初期理解得不一样,这个指针动态变化,导致产生的字符串数组也在动态变化。
原文地址:https://www.cnblogs.com/3120931037cnk/p/7642974.html