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 160 views
160 views asked Feb 9, 2023 by avibootz
1 answer 107 views
1 answer 79 views
1 answer 115 views
115 views asked Feb 10, 2023 by avibootz
3 answers 177 views
177 views asked Feb 9, 2023 by avibootz
1 answer 135 views
...