![]() |
|
#1
|
||||
|
||||
Convert Characters into Decimal value of ASCIIHello Everyone
I need to convert Characters into Decimal values of ASCII in C like if I type A i need to have 65 and similarly if I type AA I need to add up them and get 130. Please help me regarding this. Thank you for your help in advance. |
|
#2
|
|||
|
|||
Re: Convert Characters into Decimal value of ASCIIQuote:
Internally they are the same. That is: a char is an integer data type. I/O routines do the conversions for you so that you can see characters rather than their decimal values. Your program does not need to convert anything. In most systems these days the largest char value is 127, so you will probably want to use ints to hold the value of the arithmetic expressions. CPP / C++ / C Code:
Code:
The arithmetic is done with ints (this is automatic in C) and the value is stored as an int, so the user program doesn't have to "convert" anything. Regards, Dave |
|
#3
|
||||
|
||||
Re: Convert Characters into Decimal value of ASCIIHi Dave
Thank you for your Reply Dave. But I need arrays of Characters or strings to be converted into its decimals form. Like User may give any input like "a" or "abc" or "abcdef" or "abcAWe" and I need to sum all their decimal values and give output like 97 or 294 or 597. Thank you. |
|
#4
|
|||
|
|||
Re: Convert Characters into Decimal value of ASCIIQuote:
Just add them up, as I indicated in my example. If you have a string of characters, then make a loop to step through the string and add each character as you go. CPP / C++ / C Code:
Output might look something like: Code:
Regards, Dave |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary to Decimal Conversion | Saberwing | C Programming Language | 5 | 28-Dec-2006 15:57 |
| How to convert from Ascii to Hexadecimal in C program | Kennice Low | C Programming Language | 2 | 29-Sep-2006 11:30 |
| Roman to decimal to roman | SpudNuts | C++ Forum | 2 | 16-Feb-2005 20:44 |
| Problem with int mixed with char,... | leitz | C++ Forum | 17 | 07-Dec-2004 21:56 |
| Hex Result giving strange answers. | Rosdahale | C Programming Language | 6 | 07-Dec-2004 21:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The