Question : how to transform a char to ascii code in c
Answered by : jolly-jay-7i51qeuncsy0
int a_as_int = (int) 'a';
Source : https://stackoverflow.com/questions/5322056/how-to-convert-an-ascii-character-into-an-int-in-c/37736710#:~:text=A%20char%20value%20in%20C,it%20with%20(int)c%20. | Last Update : Mon, 29 Jun 20
Question : char ASCII in c
Answered by : open-okapi-3lhonygoee5p
#include <stdio.h>
int main()
{
/*
When a character is entered by the user in the above program,
the character itself is not stored. Instead, an integer value (ASCII value) is stored.
And when we display that value using %c text format,
the entered character is displayed. If we use %d to display the character,
it's ASCII value is printed.
*/ char chr; printf("Enter a character: "); scanf("%c",&chr); printf(" char in ASCII value %d.", chr); printf("You entered %c.", chr); return 0;
}
Source : https://www.programiz.com/c-programming/c-input-output | Last Update : Tue, 08 Mar 22