Solved

function to obtain the value of a char in integer

Posted on 2006-05-10
Medium Priority
176 Views
Last Modified: 2013-11-20
Hello,
I wanna know which one is the function to obtain the value of a char and the against function.

I mean

c = function("a")   c = 65
d = function(65)   d = "a"

Regards
0
Question by:1469
• 3
5 Comments

LVL 45

Assisted Solution

AndyAinscow earned 375 total points
ID: 16647621
char c = 'A';
int i = (int)c;  //i = 65
char z = (char)65;  //z is 'A'
0

LVL 48

Accepted Solution

AlexFM earned 375 total points
ID: 16647630
int IntFromChar(char c)
{
return (int)c;
}

char CharFromInt(int n)
{
return (char)n;
}

But this is better to do using casting:

int n = (int)'a';
char c = (char)65;
0

LVL 45

Expert Comment

ID: 16648111
Grade 'B' ?
0

Author Comment

ID: 16648954
Uhm¿?
0

LVL 45

Expert Comment

ID: 16648976
Why a grade B - you got example code/functions to do exactly what you asked for.
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.