1

I have a vector which contains strings:

vector<string> vectorStr = { "0x6c", "0x9f", "0x71", ... };

How do i convert the CONTENT of the strings to chars?. Preferable to a char-array, which in the end looks like:

char charArray[] = { 0x6c, 0x9f, 0x71, ... };

Seems like i am the first human in history of computer science who has to solve this problem. Everyone else just wants to convert a string into a char-Array, which is not what i want.

J Doe
  • 53
  • 7
  • 2
    Just use an [stoi](https://en.cppreference.com/w/cpp/string/basic_string/stol) function with a radix of 16. You might need to remove the hex prefix. – vandench Sep 08 '21 at 15:28
  • 4
    Does this answer your question? [C++ convert hex string to signed integer](https://stackoverflow.com/questions/1070497/c-convert-hex-string-to-signed-integer) – Yun Sep 08 '21 at 15:29
  • 2
    "_Seems like i am the first human in history of computer science who has to solve this problem_" :-) One shouldn't laugh at desperation, but that _was_ funny. – Ted Lyngmo Sep 08 '21 at 15:30
  • 1
    thanks, your answered helped me to solve this problem. Wish i could upvote :/ – J Doe Sep 08 '21 at 15:38
  • You can update the accepted answer in the linked duplicate if you believe it is a good solution to the problem stated in that question. – drescherjm Sep 08 '21 at 16:22

0 Answers0