在一堆字符串中查找指定的单个字符(二重指针)

我们使用指针数组char ** strings来储存一堆字符串,value为指定要查找的那个单个字符
因为*strings只能存储一个字符串,那么套用二重指针就是可以存储一系列字符串,即字符串数组

#include <stdio.h>

#define TRUE 1
#define FALSE 0

int find_char( char ** strings, char value )
{
	char * str;//用str指针暂时存储我们现在正在查找的字符串
	
	while( ( str = *strings++ ) != NULL )//查找列表中的每个字符串,只要不为NULL那么就把当前的字符串赋值给str,并且在str中查找是否有指定字符串;
										//最后再把指针移向下一个字符串
	{
		while( *str != '' )//查找str中每个字符是否是我们需要的那个
		{
			if( *str++ == value )
				return TRUE;
		}
	}
	return FALSE;
}
原文地址:https://www.cnblogs.com/yuzilan/p/10626159.html