系统相关
首页 > 系统相关> > linux c 输出信息到console

linux c 输出信息到console

作者:互联网

static void console_log(const char *format, ...) {
  static FILE *fpConsole;

  if (fpConsole == NULL) {
    fpConsole = fopen("/dev/console", "w");
  }

  if (fpConsole != NULL) {
    char aMsg[3584];
    va_list va;
    va_start(va, format);
    int nRet;
    if (((nRet = vsnprintf(aMsg, sizeof(aMsg), format, va)) < 0) ||
        (nRet >= (int)sizeof(aMsg))) {
      fprintf(fpConsole, "%s: nRet=%d, sizeof(aMsg)=%d\n", __FUNCTION__, nRet,
              sizeof(aMsg));
    }
    va_end(va);
    fprintf(fpConsole, "%s\n", aMsg);
  }
}

 

标签:va,console,输出,aMsg,nRet,fpConsole,linux,sizeof
来源: https://www.cnblogs.com/Malphite/p/10405557.html