[問題] string轉unsigned char

作者: ko13579ko (~逸)   2014-04-12 00:24:45
這個應該是新手問題 請多多見諒
有一字串
string a="01a2fddc";
unsigned char b[4];
想將此字串寫入b中
b[0]=0x01
b[1]=0xa2
b[2]=0xfd
b[3]=0xdc
請問要怎麼轉換
可以讓a每兩個位元
以b每一個byte表示
作者: i386 (i386 cpu)   2014-04-12 03:15:00
作者: bab7171   2014-04-12 08:32:00
strncpy, printf 用%X
作者: EdisonX (卡卡獸)   2014-04-12 14:26:00
google : sscanf , stringstream

Links booklink

Contact Us: admin [ a t ] ucptt.com