delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/01/31/09:36:26

From: "Zimba" <zimba AT zamba DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: va_list args
Date: Wed, 31 Jan 2001 15:08:15 +0100
Organization: Guest of France Telecom Oleane's newsreading service
Lines: 32
Message-ID: <9596dt$493$1@s1.read.news.oleane.net>
References: <9593n9$4lb$1 AT snoopy DOT bndlg DOT de>
NNTP-Posting-Host: 194.206.159.21
X-Trace: s1.read.news.oleane.net 980950269 4387 194.206.159.21 (31 Jan 2001 14:11:09 GMT)
X-Complaints-To: abuse AT oleane DOT net
NNTP-Posting-Date: Wed, 31 Jan 2001 14:11:09 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

This is what I use in some of my programs to redirect output somewhere (you
don't have to flush):

#include <stdio.h>
#include <string.h>
#include <stdarg.h>

/*
 * Use as you would use printf.
 */
int redir_printf(const char *format, ...)
{
  /*
   * Declare other local variables here.
   */
  int count;

  va_list ap;
  va_start(ap,format);

  count = vfprintf(outstream,format,ap);
  fflush(outstream);
  va_end(ap);

  return count;
}


Best regards,
Clemens


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019