home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / edit / viewer / kbtest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-03  |  1.3 KB  |  60 lines

  1. /* * * * KBTEST.C * * * *
  2.   Robin Anderson 10-3-92
  3.   Test out keyboard characters in both dos & (sun) unix.
  4.  
  5.   Ah yes, the joy of "portable" C.  Everything of any substance
  6.   requires an OS specific function!
  7. ........................................................... */
  8.  
  9. #include <stdio.h>
  10.  
  11. #ifdef __TURBOC__
  12. #include <conio.h>
  13. #else
  14. #include <curses.h>
  15. #endif
  16.  
  17. void
  18. main()
  19. {
  20.    char ch;
  21.  
  22. #ifndef __TURBOC__
  23.    initscr( );
  24.    cbreak( );
  25.    noecho( );
  26. #endif
  27.    ch = (char) 0;
  28.    while ( ( ch != (char) 13) && ( ch != (char) 10) )
  29.    {
  30.  
  31. #ifdef __TURBOC__
  32.       printf( "\nPress any key: ");
  33.  
  34.       /*  read a char using turbo c "conio" routine:  */
  35.       ch = getch( );  /*  no echo, may return 0 for extended codes  */
  36.       if ( ch == (char) 0)
  37.       {
  38.          printf( "0 (extended) + ");
  39.          ch = getch( );
  40.       }  /*  leading null for a pc extended char?  */
  41.       printf( "%d <- ascii code\n", (int) ch);
  42. #else
  43.       printw( "\nPress any key: ");
  44.       refresh( );
  45.  
  46.       /*  read a char using system v "curses" routine:  */
  47.       ch = getch( );
  48.       printw( "%d <- ascii code\n", (int) ch);
  49.       refresh( );
  50. #endif
  51.    }  /* until enter/return or linefeed */
  52.  
  53. #ifndef __TURBOC__
  54.    endwin( );
  55. #endif
  56. }
  57.  
  58.  
  59. /* ****** EOF: KBTEST.C ****** */
  60.