void swap( char* pDst, char* pSrc ) { char* pRunner( pSrc ); while( *pRunner ) ++pRunner; int len = pRunner - pSrc; int s8 = len >> 3; while( s8-- ) { double temp = *(double*)pSrc; *(double*)pSrc = *(double*) pDst; *(double*)pDst = temp; pDst += 8; pSrc += 8; } if( len & 0x4 ) { int temp = *(int*) pSrc; *(int*)pSrc = *(int*)pDst; *(int*)pDst = temp; pDst += 4; pSrc += 4; } if( len & 0x2 ) { short temp = *(short*) pSrc; *(short*)pSrc = *(short*)pDst; *(short*)pDst = temp; pDst += 2; pSrc += 2; } if( len & 0x1 ) { char temp = *pSrc; *pSrc = *pDst; *pDst = temp; } } 功能:交换字符串。