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 115 views
1 answer 146 views
1 answer 277 views
1 answer 82 views
2 answers 286 views
1 answer 156 views
...