I have this number in hex string:
002A05.
I need to set 7-th bit of this number to 1, so after conversion I will get
022A05 >
You asked about strtol specifically, so to answer your question, just add padding after you convert the number with strtol:
strtol
const char *s = "002A05"; int x = strtol(s, NULL, 16); x |= (1<<17); printf("%.6X\n",x);