编写一个程序 将字符串翻转

# include <stdio.h>  

char* reverse_string(char *string)
{
	char temp;
	char *top = string;
	char *end = string;
	while (*end != '\0')
	{
		end++;
	}
	end--;

	for (; top < end; (top ++ && end--))
	{
		temp = *top;
		*top = *end;
		*end = temp;
	}
	return string;
}

int main()
{
	char a[] = "qwetrytuy";
	printf("%s\n", reverse_string(a));
	return 0;
}

你可能感兴趣的:(编写一个程序 将字符串翻转)