Alphabet to ascii conversion

How to convert letters to ASCII

This is possible under C++

include <stdio.h>

void main()

{

int a;

char b=’A’;

a=b;

printf (“%d”,a);//The result after running is 65, which is the ASCII code corresponding to A.

}

Or:

include <stdio.h>

void main()

{

char b=’A’;

printf (“%d”,b);

}

This also output the ASCII code of A .

Conversion of c language characters to ASCII

#include<stdio.h>

voidmain()

{

unsignedchara;

printf(“enterchar:”);

scanf(“%C”,&a);

printf(“ascii=%d”,a);//Forced conversion to ascii

}

Expanded Information

The origin of the ASCII encoding of the C language

ASCII code

A Binary bit (Bit) has two states, 0 and 1. A byte (Byte) has 8 binary bits with 256 states, each state corresponds to a symbol, that is 256 symbols from 00000000 to 11111111. the United States developed a set of correspondence between English characters and binary bits, called ASCII code, which is used to this day.

ASCII code provides 128 English characters and binary correspondence, occupying a byte (in fact, only occupies a byte of the latter 7 bits, the first 1 bit of the unified provisions for 0). For example, the ASCII code for the letter a is 01100001, so for the time being you can understand that the letter a is converted to 01100001 before it is stored in memory, and 01100001 is also converted to a when it is read.