How to convert unsigned short to char in C

2 Answers

0 votes
#include <stdio.h> 

int main(void) 
{ 
	unsigned short s = 100;
	char ch = (char)s;
	
	printf("%c\n", ch);
	
    return 0; 
} 
  
  
  
/*
run:
  
d
 
*/

 



answered Aug 8, 2019 by avibootz
0 votes
#include <stdio.h> 

int main(void) 
{ 
	unsigned short s = 0xAF;
	char ch = (char)s;
	
	printf("%c\n", ch);
	
    return 0; 
} 
  
  
  
/*
run:
  
ยป

*/

 



answered Aug 8, 2019 by avibootz

Related questions

3 answers 170 views
170 views asked Feb 9, 2023 by avibootz
1 answer 114 views
1 answer 86 views
1 answer 118 views
118 views asked Feb 10, 2023 by avibootz
3 answers 189 views
189 views asked Feb 9, 2023 by avibootz
1 answer 136 views
...