//CLEAR THE BUFFER SO PROGRAM DOES NOT END AFTER PRESSING ENTER
void clearBuffer(void) { while(getchar()!='\n') { } } //CONVERTING ASCII TO INTEGER FUNCTION
int asciiToInteger(int ascii) //Function to convert ASCII to decimal
{ ascii=ascii-0x30; //Integer convertion by subtractin hex number return ascii;
}
//********************************* MAIN FUNCTION****************************************
int main() {
//VARIABLES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! char key; int character;
//WHILE THE CONDITION IS MET REPEAT!!!!!!!!!!!!!!!!
while(key!='q') {
printf("Enter a character:\n"); character=asciiToInteger(getchar()); printf("\nThe integer representation of the character (%c - Ox%x) is %d\n",(character+30),(character+0x30),character);
No comments:
Post a Comment