怎么从字符串中取出字符?
我是一个刚学VC的菜鸟,想请教高手一下怎么从字符串中取出一个一个的字符,比方说有一个字符串CString str="1A 23 13 2A 3B 3C 4E ",想从中取出'1A','23','13','2A','3B','3C','4E'.谢谢各位高手了。
void uti_unpack(unsigned char *pSrc, unsigned char * pDest, int len) { unsigned char ch1, ch2; for( int i = 0; i < len; i++ ) { ch1 = (pSrc[i] & 0xF0) >> 4; ch2 = pSrc[i] & 0x0F; ch1 += ( (ch1 > 9 ) ? 0x37 : 0x30 ); ch2 += ( (ch2 > 9 ) ? 0x37 : 0x30 ); pDest[i*2] = ch1; pDest[i*2 + 1] = ch2; } }
void uti_pack(unsigned char *pSrc, unsigned char *pDest, int len) { char ch1, ch2; for( int i = 0; i < (len / 2); i++ ) { ch1 = pSrc[i*2]; ch2 = pSrc[i*2 + 1]; (ch1 >= 'a' && ch1 <= 'z') ? (ch1 -= 32) : (ch1); (ch2 >= 'a' && ch2 <= 'z') ? (ch2 -= 32) : (ch2); ch1 -= ( (ch1 > '9' ) ? 0x37 : 0x30 ); ch2 -= ( (ch2 > '9' ) ? 0x37 : 0x30 ); pDest[i] = ( ch1 << 4 ) | ch2; } }