---
title: "c实现的字符串翻转"
author: "smallsilver"
date: "2013-02-21T00:00:01Z"
tags: []
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2013-02-21T00:00:01Z"
id: 1810822
url: "https://wangde.iteye.com/blog/1810822"
---

用c实现的字符串翻转：

```c

//字符串翻转
void reverse(char *str)
{
	char *end = str;
	char tmp;
	if(str)
	{
		while(*end)
		{
			end++;
		}
		end--;
		while(str<end)
		{
			tmp = *str;
			*str++ = *end;
			*end-- = tmp;
		}
	}
}

```