How can I get a char in C that corresponds with a hex code stored in a character pointer?
For example, in the below, I have "2A" in char pointer hex. How do I get the * character from this?
int main() {
char* hex = "2A";
return 0;
}
How can I get a char in C that corresponds with a hex code stored in a character pointer?
For example, in the below, I have "2A" in char pointer hex. How do I get the * character from this?
int main() {
char* hex = "2A";
return 0;
}
Have you tried strtol
?
#include <stdio.h>
#include <stdlib.h>
int main () {
char *hex = "2A";
printf("%c\n", (int)strtol(hex, NULL, 16));
return 0;
}