2

iam programming in C++ and im stuck at this problem. How to convert string literally to char* in bytes. Iam not very good in working with char and strings. I want to make function that if i call it, it will look like:

char *output = MyFunct("0102030c");

and the output will be same if i would do something like this:

char test[] = {0x01, 0x02, 0x03, 0x0c};

i have no idea how would i make that, thanks for any suggestions :)

TomCrow
  • 102
  • 10
  • 3
    Have a look at the [`std::hex`](http://en.cppreference.com/w/cpp/io/ios_base/fmtflags) I/O manipulator in conjunction with a [`std::istringstream`](http://en.cppreference.com/w/cpp/io/basic_istringstream). – πάντα ῥεῖ Jun 05 '14 at 13:40
  • Thanks :) I get to work "0a" to 0x0a .. now i can make the whole thing. – TomCrow Jun 05 '14 at 13:49
  • possible duplicate of [Converting a hex string to byte array in c++.](http://stackoverflow.com/questions/17261798/converting-a-hex-string-to-byte-array-in-c) – Paul Roub May 26 '15 at 18:59

0 Answers0