首页 > 代码库 > 有个函数:char* reverse(char *buf)

有个函数:char* reverse(char *buf)

 *Author  : DavidLin   
 *Date    : 2014-12-15pm   
 *Email   : linpeng1577@163.com or linpeng1577@gmail.com   
 *world   : the city of SZ, in China   
 *Ver     : 000.000.001   
 *For     : reverse the char array/string!
 *history :     editor      time            do   
 *          1)LinPeng       2014-12-15      created this file!   
 *          2)   
 */  

char * reverse(char * buf)
{
	int len;
	char tmp;
	int i;
         
	if(NULL == buf) {
	    return NULL;
	}

	len = strlen(buf);

	for(i = 0; i < len/2; i++)
	{
	    tmp             =  buf[i];
	    buf[i]          =  buf[len -i -1];
	    buf[len -i -1]  =  tmp;
	}
	
	return buf;
}


有个函数:char* reverse(char *buf)