Assigning an ASCII value?

This is a discussion on Assigning an ASCII value? within the C Programming forums, part of the General Programming Boards category; How do you assign a characters ASCII value to a variable?...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    Angry Assigning an ASCII value?

    How do you assign a characters ASCII value to a variable?

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    int a = 'a';
    zen

  3. #3
    Sayeh
    Guest
    Or, different from the above, you could know what the ASCII value is and apply it:

    int a;

    a = 0x4F;

    or

    a = 79;


    -------------------------

    zen, it could by a wise and creative idea for you to perhaps write a small program to display the ASCII table. Virtually any computer book will have an ASCII table somewhere in it.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    Cheers

    Cheers guys

  5. #5
    Sayeh
    Guest

    ASCII Chart Code

    Here's a snippet you can run under DOS to display the displayable ASCII characters:


    ---


    /*****
    *
    * MAIN
    *
    *****
    *
    * IN: void
    * OUT: int - standard exit value
    *
    * NOTE: This is where it all starts and stops
    *
    *****/

    int main(void)
    {
    unsigned char row,
    column;
    unsigned char byte;

    row = 0x00; /* init vars */
    column = 0x00;
    byte = 0x00;

    printf("\r\n\n THE ASCII TABLE\n\r-----------------\n\n\r");

    for(row=0x00;row<0x10;row++) /* do the rows */
    {
    if(row == 0x00) /* first row, create columns headings */
    {
    printf(" | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n\r");
    printf("----+-----------------------------------------------------------------\n\r");
    };

    printf(" %02X | ",(row<<4)); /* output row heading */

    for(column=0x00;column<0x10;column++) /* do the columns */
    {
    if((byte < 0x08) || (byte > 0x0D)) /* if it's backspace, tab, etc, don't output */
    printf(" %c ",byte);
    else
    printf(" ");

    byte++;
    };

    printf("\n\r"); /* move to next row */
    };

    printf("\n\rTo use, add value at left to value at top. Example: 'N' = 0x4E.\n\r");

    return(0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ASCII character with ASCII value 0 and 32
    By hitesh_best in forum C Programming
    Replies: 4
    Last Post: 07-24-2007, 10:45 AM
  2. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  3. Office access in C/C++ NOT VC++!! :)
    By skawky in forum C++ Programming
    Replies: 1
    Last Post: 05-26-2005, 02:43 PM
  4. ascii values for keys
    By acid45 in forum C Programming
    Replies: 2
    Last Post: 05-12-2003, 08:13 AM
  5. Checking ascii values of char input
    By yank in forum C Programming
    Replies: 2
    Last Post: 04-29-2003, 08:49 AM

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