function to obtain the value of a char in integer

Posted on 2006-05-10
Last Modified: 2013-11-20
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"

Question by:1469
    LVL 43

    Assisted Solution

         char c = 'A';
          int i = (int)c;  //i = 65
          char z = (char)65;  //z is 'A'
    LVL 48

    Accepted Solution

    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;
    LVL 43

    Expert Comment

    Grade 'B' ?

    Author Comment

    LVL 43

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Unix / Linux grid computing 5 95
    Expand data scrubbing tool 13 27
    Define unique primary key 9 76
    wait notify demo infinite loop 3 66
    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    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.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

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

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

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now