I am trying to copy a byte in hex into a char buffer...

char str[15];
memcpy (str,"\x11",1);

However I need calculate the byte I am copying, dynamically, and put it in the char buffer as hex numbers...


so far I have tried using sprintf ...
int int_offset=17; //hex 11
sprintf (str_offset, "%02x", int_offset); // int int_offset=17;
This gives the correct output (hex 11)

now the problem is copying the contents of str_offset AS HEX VALUES into str (the char buffer)
when memcpy is used the values are copies as ASCII values, not hex !.

I have searched the for the answer and tried many things with the debugger , yet been unsuccessful.
Would be very grateful for any pointers ....

Code:
 
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[15],
       str_offset[4];
  	   
  int  int_offset=17;
  
  sprintf (str_offset, "%02x", int_offset);
  
  memcpy (str ,str_offset,2);
  
  return 0;
}