putchar.c

来自「8051试验程序 基础教材」· C语言 代码 · 共 32 行

C
32
字号
/*              PUTCHAR.C

   The ANSI "putchar" function.

   The putchar function writes the character c to the
   output-stream pointed to by stream. 
   The function returns the character written. If an writing 
   error  occurs the putchar shall return EOF.

   $Name: V7_dot_30A V7_dot_21A $    

   Copyright 1986 - 1999 IAR Systems. All rights reserved.
*/


#include <stdio.h>
#include <ioC8051f060.h>    

int putchar(int ch)
{
  if (ch == '\n')  {
    while (!SCON0_bit.TI0);
    SCON0_bit.TI0 = 0;
    SBUF0 = 0x0d;                         // output CR  
  }

while (!SCON0_bit.TI0);
  SCON0_bit.TI0 = 0;
  return	 (SBUF0 = ch);
}

⌨️ 快捷键说明

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