Home winapi Functions for obtaining a symbol on the ASCII code and vice versa.

Functions for obtaining a symbol on the ASCII code and vice versa.

Author

Date

Category

Is there a function with which you can get a symbol on the ASCII code, as well as the function of getting the ASCII code on the symbol?
For example:
A- & GT; 65;
90- & gt; z.


Answer 1, Authority 100%

code

# include & lt; iostream & gt;
INT MAIN (Void)
{
 Char C;
 STD :: COUT & LT; & LT; "ENTER SYMBOL:" & lt; & lt; std :: endl;
 STD :: CIN & GT; & GT; C;
 INT CODE;
 Code = C - 'A';
 STD :: COUT & LT; & LT; "Code of Symbol IS" & lt; & lt; (int) C & LT; & lt;
    "and difference with 'a' is" & lt; & lt; code & lt; & lt; std :: endl;
 // In the previous line, the attraction of Int is needed, otherwise it will not work by the OOP magic,
 // T.K. COUT is a very cunning object defining the type of deposited
 // expressions how to display it on the screen
 Return 1;
}

perfectly compiled and works

gaal @ linux-lybs: ~ & gt; G ++ 1.CPP
Gaal @ Linux-Lybs: ~ & gt; ./a.out.
ENTER SYMBOL:
A.
Code of Symbol IS 65 and Difference WITH 'A' IS 0
Gaal @ Linux-Lybs: ~ & gt; ./a.out.
ENTER SYMBOL:
B.
Code of Symbol IS 66 and Difference WITH 'A' IS 1

Answer 2, Authority 67%

judging by the tag of you si)
Converting a symbol in ASCII:

// c, with c type-casting
char cmycharacter = 'a';
int imyasciivalue = (int) CMYCHARACTER;
// C++, WITH C++ Type-Casting
char cmycharacter = 'a';
int imyasciivalue = static_cast & lt; int & gt; (CMYCHARACTER);

Code Conversion to Symbol:

int asciival = 65;
char asciichar = static_cast & lt; char & gt; (asciival);

or

char asciickhar = asciival;

Answer 3

There are no functions – there are functions of type of type.

# include & lt; iostream & gt;
Using Namespace STD;
INT MAIN ()
{
  Char C;
  INT ASCII;
  COUT & LT; & LT; "Enter the symbol:";
  CIN & GT; & GT; c;
  COUT & LT; & LT; "ASCII code:" & lt; & lt; (int) C & LT; & LT; Endl;
  COUT & LT; & LT; "Enter the Symbol ASCII code:";
  CIN & GT; & GT; ASCII;
  COUT & LT; & LT; "Commolve:" & lt; & lt; (Char) ASCII & LT; & LT; Endl;
  Return 0;
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions