terminal.c

来自「DOS下」· C语言 代码 · 共 42 行

C
42
字号
/************************************************************/
/************************************************************/
/* Simple terminal program for Microsoft C 5.1 */
/* Copyright 1989, Quinn-Curtis  */
/************************************************************/
/************************************************************/

# include <stdlib.h>
# include <stdio.h>
# include "asyncpec.h"

     int err;
     char transmit_ch;
     char receive_ch;

void main()

{ /* Com port 1, 9600 baud, no parity, 1 stop bit, 8 data bits */
  open_com(0,9600,0,1,8,&err);
  do {
     do {
       transmit_ch = getche();  /* Get Character with echo */
       if (transmit_ch != 27) send_com(transmit_ch,&err);
       /* Grab characters until CR or ESC */
     } while ((transmit_ch != 13) && (transmit_ch != 27));
     putch(10); /* Send a LF to screen */
     do { /* Read com buffer until no characters left */
       check_com(&receive_ch,&err);
       if (err==0) {
         putch(receive_ch);  /* If good character the write to screen*/
         if (receive_ch==13) putch(10);  /* Add LF if CR */
       }
       else if (err==7){
           putch(receive_ch);
           printf("BUFFER OVERRUN");
           reset_buffer();
        }
     } while (err == 0);
  } while (transmit_ch != 27); /* Exit program by pressing ESC key */
  close_com();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?