Phr0zen_Penguin

Interactive Arrow Keys

Nov 9th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <windows.h>
  4.  
  5. void main()
  6. {
  7.     int option,option2, pos=0;
  8.    while(1)
  9.    {
  10.     option=getch();
  11.    if(option==0)
  12.    {
  13.        option2=getch();
  14.       if(option2 == 72)
  15.       {
  16.           pos+=1;
  17.           printf("%d", pos);
  18.       }
  19.       else if(option2 == 80)
  20.       {
  21.            pos-=1;
  22.           printf("%d",pos);
  23.        }
  24.    }
  25.     system("pause");
  26.    system("cls");
  27.    }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment