Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-02-2003, 02:10 AM   PM User | #1
chrismiceli
Regular Coder

 
Join Date: Sep 2002
Location: Louisiana
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
chrismiceli is an unknown quantity at this point
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>
__________________
DevEdge - MSDN - DevGuru

Last edited by chrismiceli; 01-02-2003 at 02:13 AM..
chrismiceli is offline   Reply With Quote
Old 01-02-2003, 09:58 AM   PM User | #2
Borgtex
Regular Coder

 
Join Date: Aug 2002
Location: Spain
Posts: 420
Thanks: 0
Thanked 0 Times in 0 Posts
Borgtex is an unknown quantity at this point
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!
Borgtex is offline   Reply With Quote
Old 01-02-2003, 06:10 PM   PM User | #3
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
Quote:
Originally posted by Borgtex
Hummm that's not a javascript, so maybe this post should go to Computer Programming to avoid confusions
True.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 01-02-2003, 11:07 PM   PM User | #4
chrismiceli
Regular Coder

 
Join Date: Sep 2002
Location: Louisiana
Posts: 576
Thanks: 0
Thanked 0 Times in 0 Posts
chrismiceli is an unknown quantity at this point
sorry
__________________
DevEdge - MSDN - DevGuru
chrismiceli is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:11 PM.


Advertisement
Log in to turn off these ads.