How to manipulate ascii value of letters?

This is a discussion on How to manipulate ascii value of letters? within the C++ Programming forums, part of the General Programming Boards category; How to manipulate ascii value of letters?
For example, if the ascii value of a and b is 0 and ...

How to manipulate ascii value of letters?

How to manipulate ascii value of letters?
For example, if the ascii value of a and b is 0 and 1, add 1 to the ascii value of a, then the character is changed from a to b.
I know how to do it with array but it is clumsy.
Is there any pre-defined function of certain library to get the ascii value of letters?I searched it and couldn't find any.
Thanks in advance!

Could you elaborate on what you mean by "manipulate ascii value of letters"?

For example, if the ascii value of a and b is 0 and 1, add 1 to the ascii value of a, then the character is changed from a to b.
I know how to do it with array but it is clumsy.
Is there any pre-defined function of certain library to get the ascii value of letters?I searched it and couldn't find any.

There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

Here the input was stored in "input". But in the next line you redeclare the "input" to be the same as undeclared "letter".Just don't use "letter" and operate solely on "input" and "asc". You should also change to this code:

Code:

for (int a=0;a<input.length();a++)
{
asc[a]=input[a];
}

Or better yet, use only the "input" variable and manipulate each char inside the variable.

FYI, a char is actually a number between 0 to 255 (unsigned) or -127 to 128 (signed). You could say that it's a shorter version of integer. So, I think if you wanted to operate on char, use char. Although if your char is 255 and you add them, it will loop back to 0+the adder (CMIIW, forgot this one).

In general, its the context that tells the program if a number represents an ASCII character. If there's a 49 somewhere in memory, it might represent 49, or it might represent an ASCII '1'. It might represent something else, like a machine-code instruction or the binary state of something. (Or the binary states of 8 things.) You and/or your program know what the variable is used for. cout will check the type, and if 49 is stored in a type-char it will automatically display 1.