Converting words into ASCII values

This is a discussion on Converting words into ASCII values within the C Programming forums, part of the General Programming Boards category; I was just wondering whether it is possible to convert characters into their ASCII values or values in the alphabet ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    60

    Converting words into ASCII values

    I was just wondering whether it is possible to convert characters into their ASCII values or values in the alphabet easily without needing a load of if statements.

    The only way I can think of doing it is the afformentioned by using an if and 25 else if statements.

    Thanks

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,456
    char a = 'a';
    int x = a;
    printf ("Char %c - ASCII %x", a, x);
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    60
    thanks I thought it would error because of the different data types.

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    C is not exactly built around type-safety. A char is not much more than an 8 bit signed integer.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using structures to assign unique values to words?
    By coreyt1111 in forum C++ Programming
    Replies: 3
    Last Post: 11-29-2006, 10:19 AM
  2. Converting words to *'s
    By FingerPrint in forum C++ Programming
    Replies: 5
    Last Post: 10-21-2006, 03:40 PM
  3. Replies: 11
    Last Post: 03-24-2006, 10:26 AM
  4. Do arrow keys have two ascii values
    By vaibhav in forum C++ Programming
    Replies: 4
    Last Post: 01-16-2006, 07:03 AM
  5. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 09:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21