swab函数交换字符串中相邻两个字节;
void _swab( char *src, char *dest, int n );
char *src: 要拷贝、转换的字符串,
char *dest,转换后存储到dest所表示的字符串,
int n要拷贝、转换的字节数;
所属库是 stdlib.h;
VC里面可以直接用;
void CMyswabView::OnDraw(CDC* pDC)
{CMyswabDoc* pDoc = GetDocument();ASSERT_VALID(pDoc);// TODO: add draw code for native data herechar* hello= "ABCDMN";char temp[32];memset(temp, 0, sizeof(temp));swab(hello, temp, strlen(hello));pDC->TextOut(50, 50, temp);swab(temp, temp, strlen(temp));pDC->TextOut(50, 80, temp);
}
字符串一开始是 ABCDMN,交换之后输出,再交换又输出;