C function to determine whether the string is a palindrome

int isHuiWenStr(const char* str)
{
	int i, len;
	int found = true;

	if (str == NULL) return -1;

	len = strlen(str);

	for (i = 0; i < len / 2; i++)
	{
		if (*(str + i) != *(str + len - i - 1))
		{
			found = 0;
			break;
		}
	}

	return found;
}

int main()
{
	char strSrc[] = "012343210";

	reverseStr2(strSrc);

	printf("%d\n", isHuiWenStr(strSrc));

	system("pause");
	return 0;
}
Published 48 original articles · won praise 1 · views 2502

Guess you like

Origin blog.csdn.net/lpl312905509/article/details/104080688