ITeye博客

2017 年文章归档

共 3 篇文章

hexadecimal string to byte array in python

hex_string = "deadbeef" Convert it to a string (Python ≤ 2.6): hex_data = hex_string.decode("hex") hex_data "\xde\xad\xbe\xef" or since Python 2.7 and Python 3.0: bytearray.fromhex(hex_data) bytearray(b'\xde\xad\xbe\xef')

2017-09-25 09:58

size of array

#define num(x) (sizeof (x) / sizeof (*x)) int main(){ int number[10] = {1,1,1,1,1,1}; char *teststr[20] = {"","","","","","","","",""}; printf("Size of number[10] is %d\n", (int)num(number)); printf("Size of teststr[20] is %d\n", (int)num(teststr)); return 0; }

2017-08-06 22:53 · c

std::map

std::map<char,int> mymap; std::map<char, set<string> > mmap; mmap['a'].insert("hello"); mmap['a'].insert("hello1"); map<char, set<string> >::iterator iter = mmap.begin(); for(;iter!=mmap.end();++iter){ cout << iter->first << endl; set<string>::iterator itt = iter->second.begin(); for (;itt != iter-…

2017-08-06 22:41 · c++