Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: ascii [in c]

  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ascii [in c]

    a while ago on the javascript board someone asked how to find out the ascii code of a letter, a response gave him the anser and a nice little page that when a key was pressed it would alert the ascii code, well i just started to learn c about a week ago, and i figured out how to do it.
    Code:
    #include <stdio.h>
    
    void main() {
            char key;
            printf("press any key:");
            key=getchar();
            printf("the key was %c\n",key);
            printf("the ascii code is %i\n",key);
    }
    this was tested on redhat 8.0 using the gcc compiler, and it worked great. BTW if you want to find out the ascii code of like the arrow key (->) hit it and then hit enter, it should work.
    p.s. if you use dos and windows, chang getchar() to getch(); and add #include <conio.h>
    Last edited by chrismiceli; 01-02-2003 at 03:13 AM.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hummm that's not a javascript, so maybe this post should go to Computer Programming to avoid confusions
    Don't resist to assimilation. Billions of Borgs can't be wrong!

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Originally posted by Borgtex
    Hummm that's not a javascript, so maybe this post should go to Computer Programming to avoid confusions
    True.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry


  •  

    LinkBacks (?)

    1. 04-08-2014, 06:06 AM

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •