Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int asctohex(char h);
- int main(){
- printf("%d",asctohex('A')); //Passing asctohex any ascii character will give you back the interger HEX value
- return 0;
- }
- int asctohex(char h){
- if(h == '0'){
- return 0;
- }
- else if(h == '1'){
- return 1;
- }
- else if(h == '2'){
- return 2;
- }
- else if(h == '3'){
- return 3;
- }
- else if(h == '4'){
- return 4;
- }
- else if(h == '5'){
- return 5;
- }
- else if(h == '6'){
- return 6;
- }
- else if(h == '7'){
- return 7;
- }
- else if(h == '8'){
- return 8;
- }
- else if(h == '9'){
- return 9;
- }
- else if(h == 'A'){
- return 10;
- }
- else if(h == 'B'){
- return 11;
- }
- else if(h == 'C'){
- return 12;
- }
- else if(h == 'D'){
- return 13;
- }
- else if(h == 'E'){
- return 14;
- }
- else if(h == 'F'){
- return 15;
- }
- return NULL;
- }
Add Comment
Please, Sign In to add comment