How to convert char to ascii value in C

1 Answer

0 votes
#include <stdio.h>

int main() 
{                       
    char ch = 'a';
    printf("%d\n", (int)ch);
	printf("%d\n", ch);
		
	int n = (int)ch;
    printf("%d\n", n);
        
    return 0; 
} 
     
     
     
/*
run:
     
97
97
97
     
*/

 



answered Nov 27, 2019 by avibootz

Related questions

1 answer 290 views
290 views asked Nov 27, 2019 by avibootz
1 answer 306 views
306 views asked Nov 27, 2019 by avibootz
1 answer 294 views
294 views asked Nov 27, 2019 by avibootz
1 answer 323 views
2 answers 388 views
1 answer 322 views
322 views asked Nov 30, 2019 by avibootz
1 answer 293 views
293 views asked Nov 30, 2019 by avibootz
...