Hex to char array in C

后端 未结 11 1135
广开言路
广开言路 2020-11-30 09:04

Given a string of hex values i.e. e.g. \"0011223344\" so that\'s 0x00, 0x11 etc.

How do I add these values to a char array?

Equivalent to say:

<
11条回答
  •  情书的邮戳
    2020-11-30 09:50

    First, your question isn't very precise. Is the string a std::string or a char buffer? Set at compile-time?

    Dynamic memory is almost certainly your answer.

    char* arr = (char*)malloc(numberOfValues);
    

    Then, you can walk through the input, and assign it to the array.

提交回复
热议问题