How to change ASCII to Alphabet.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • encryptor
    New Member
    • Sep 2010
    • 1

    How to change ASCII to Alphabet.

    i wonder how to change a number to alphabet. like ASCII to alphabet.

    Code:
    int main()
    
    int i;
    char c;
    
    cout<<"write a while number"<<endl;
    cin>>i;
    c=i;
    cout<< c <<endl;
    
    like this looks my code but it does not function properly as it should be.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Well, if a char has a value of 'A', then if you assign the char to an int you can see the value of the int.

    If you do this backwards, you have converted an int to a member of the alphabet.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      @encryptor: I don't understand what you want to do. Please provide a simple example showing an input value and a corresponding output value.

      Comment

      • Rizladonovich
        New Member
        • Sep 2010
        • 13

        #4
        Your code set value to i from input (cin).

        If you enter 65, and then set c = i, c holds 65 witch interprets as 'A' as character. "cout'ed" this gives "A" (as long as your PC does not have a very very strange coding table).

        Execution would be:
        Code:
        write a while number
        88<enter>
        X
        
        or
        
        write a while number
        65<enter>
        A
        
        and so on.

        Comment

        Working...