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);
  }
}

 

上一篇:内存管理 - 4.vmalloc


下一篇:va和tn玩游戏哪个好 va和tn哪个伤眼睛