How to get ASCII values

How to get the ascii values....
for getting integer types we use %d ...
like that what we use for ASCII values

for example.

printf("Enter A value:");
scanf("%d",&a);
switch(a)
{
case 1:
printf("case 1");
break;
case 2:
printf("case 2");
break;
}

in the above program if we enter 1 the 'a' value is assigned to 1 and according to 'a' value it will switches to respected case ....like this how to get the ASCII values.

for example:

printf("press UP arrow for add and DOWN arrow for sub:");/* any special charaters*/
____________________________________(what statement we have to use here).
switch(a)
{
case 234:   /* just for example ACSII value of UP arrow */
printf("add");
break
case 345:   /* just for example ACSII value of DOWN arrow */
printf("sub");
break;
}

or any other programs to get the special charater or any button in keyboard.
please clear my doubt.....
If you load the input in an array of numbers it will automaticly be in ascii code. For example: (i use cin)
1
2
char buffer[11];
cin >> buffer;

Now buffer wil contain the ASCII codes of your input. The only problem here would be that ASCII codes go from 0 to 255. So you will need to use unsigned char buffers probably.
But I don't think ASCII contains arrow values.
not only for arrow for any special characters .........

actually mine qusetion is that how to give interrupt while program is executing and by the given interrupt values the respected next statement of the program have to executed.......

It depends entirely upon your OS and/or the library you are using to do it.

I presume you are on DOS or Windows?

For DOS you can use the <conio.h> getch().

For Windows you can use pdcurses or the Windows Console Functions directly.

PDcurses
http://pdcurses.sourceforge.net/

Windows example
http://www.cplusplus.com/forum/articles/7312/#msg33734

Good luck!
Last edited on
Topic archived. No new replies allowed.