求出一个字符串中出现一次的字符

//第一个只出现一次的字符
char FirstNotRepeatingChar(char *pString)
{
	if (pString == NULL)
		return '\0';
	const int tableSize = 256;
	unsigned int hasTable[tableSize];
	for (unsigned int i = 0; i < tableSize; i++)
		hasTable[i] = 0;

	char *pHashKey = pString;
	while (*pHashKey != '\0')
		hasTable[*(pHashKey++)]++;

	pHashKey = pString;
	while (pHashKey != '\0')
	{
		if (hasTable[*pHashKey] == 1)
			return *pHashKey;
		pHashKey++;
	}
	return '\0';
}

你可能感兴趣的:(求出一个字符串中出现一次的字符)