printf.c

来自「异步通讯C语言例行子程序」· C语言 代码 · 共 25 行

C
25
字号
/* A module of ASYNCx.LIB version 1.02 */

#include <stdarg.h>
#include <stdio.h>
#include "asyncdef.h"

/*********************************************************************
 Format the variable argument list according to the format string and
 send the resulting text to port p. Return the number of characters
 sent to the port, or -1 if there is an error.
*********************************************************************/
int a_printf(register ASYNC *p,char *format,...)
{register char s[1024]; /* a large string */
 int i;
 va_list ap;
 if (p)
  {va_start(ap,format);
   vsprintf(s,format,ap);
   for(i=0;i<1024 && s[i];i++)
     a_putc((unsigned char)s[i],p);
   return i;
  }
 return -1;
} /* end of a_printf(p,format,...) */

⌨️ 快捷键说明

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