Welcome to Dream.In.Code
Become a C++ Expert!

Join 150,055 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,730 people online right now. Registration is fast and FREE... Join Now!




convert to ASCII

 
Reply to this topicStart new topic

convert to ASCII

amberm
1 Feb, 2008 - 02:22 PM
Post #1

New D.I.C Head
*

Joined: 1 Feb, 2008
Posts: 1

I am stuck on how to do this problem. I got as far as getting an output that say, "if the input is A, the output is 0." However, the problem is that i need that integer to be the corresponding ASCII for the letter input.
User is offlineProfile CardPM
+Quote Post

GWatt
RE: Convert To ASCII
1 Feb, 2008 - 03:33 PM
Post #2

human inside
Group Icon

Joined: 1 Dec, 2005
Posts: 2,359



Thanked: 31 times
Dream Kudos: 500
My Contributions
You can convert a character to integer and simply print out the integer.
User is online!Profile CardPM
+Quote Post

Bench
RE: Convert To ASCII
1 Feb, 2008 - 03:54 PM
Post #3

D.I.C Addict
Group Icon

Joined: 20 Aug, 2007
Posts: 686



Thanked: 24 times
Dream Kudos: 150
Expert In: C/C++

My Contributions
QUOTE(amberm @ 1 Feb, 2008 - 10:22 PM) *

I am stuck on how to do this problem. I got as far as getting an output that say, "if the input is A, the output is 0." However, the problem is that i need that integer to be the corresponding ASCII for the letter input.

See what happens when you output these three int variables.
CODE
int num1 = 'A';
int num2 = 'D';
int num3 = num2 - num1;

User is offlineProfile CardPM
+Quote Post

musya
RE: Convert To ASCII
1 Feb, 2008 - 04:04 PM
Post #4

D.I.C Regular
Group Icon

Joined: 25 Apr, 2007
Posts: 296



Thanked: 1 times
Dream Kudos: 50
My Contributions
static_cast(int) biggrin.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 10:27PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month