有個函數:char* reverse(char *buf)

 *Author  : DavidLin   
 *Date    : 2014-12-15pm   
 *Email   : [email protected] or [email protected]   
 *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;
}




發佈了56 篇原創文章 · 獲贊 6 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章