How to assign hex value to char in C

2 Answers

0 votes
#include <stdio.h>
#include <inttypes.h>

int main () {
  uint8_t ch = (uint8_t)0x41;

  printf("%d %x %c\n", ch, ch, ch);
  
  return 0;
}



/*
run:

65 41 A

*/

 



answered Dec 2, 2024 by avibootz
0 votes
#include <stdio.h>
#include <inttypes.h>

int main () {
  char ch = 0x41;

  printf("%d %x %c\n", ch, ch, ch);
  
  return 0;
}



/*
run:

65 41 A

*/

 



answered Dec 2, 2024 by avibootz

Related questions

1 answer 104 views
1 answer 140 views
1 answer 272 views
1 answer 76 views
2 answers 273 views
1 answer 149 views
1 answer 155 views
...