From owner-freebsd-questions@FreeBSD.ORG Sun May 4 11:42:08 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0557106566B for ; Sun, 4 May 2008 11:42:08 +0000 (UTC) (envelope-from peter@boosten.org) Received: from smtpq1.tilbu1.nb.home.nl (smtpq1.tilbu1.nb.home.nl [213.51.146.200]) by mx1.freebsd.org (Postfix) with ESMTP id 6FE128FC32 for ; Sun, 4 May 2008 11:42:08 +0000 (UTC) (envelope-from peter@boosten.org) Received: from [213.51.146.188] (port=47290 helo=smtp3.tilbu1.nb.home.nl) by smtpq1.tilbu1.nb.home.nl with esmtp (Exim 4.60) (envelope-from ) id 1Jsccb-0008Ur-HU; Sun, 04 May 2008 13:43:13 +0200 Received: from cp268254-a.landg1.lb.home.nl ([84.25.65.88]:4922 helo=ra.egypt.nl) by smtp3.tilbu1.nb.home.nl with esmtp (Exim 4.60) (envelope-from ) id 1JscbU-0006qz-Qp; Sun, 04 May 2008 13:42:06 +0200 Received: from [127.0.0.1] (xp.egypt.nl [192.168.13.35]) by ra.egypt.nl (Postfix) with ESMTP id 4CBAC3987F; Sun, 4 May 2008 13:42:04 +0200 (CEST) Message-ID: <481DA10B.30903@boosten.org> Date: Sun, 04 May 2008 13:42:03 +0200 From: Peter Boosten User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Unga References: <336540.36159.qm@web57014.mail.re3.yahoo.com> In-Reply-To: <336540.36159.qm@web57014.mail.re3.yahoo.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 080504-0, 05/04/2008), Outbound message X-Antivirus-Status: Clean X-Spam-Score: 1.5 (+) Cc: freebsd-questions@freebsd.org Subject: Re: Variable arg function question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 May 2008 11:42:08 -0000 Unga wrote: > Hi all > > I need to implement a variable argument function in C. > The number of args are not known but the type is > known, all are strings. > > Unfortunately va_arg() [stdarg(3)] does not return > NULL or any other suitable value after processing the > arg list, it just simply crashes once the arg list is > exhausted. > > It seems there is no way to know the number of args > inside the called function. Why is it in your opinion so hard to count the number of arguments *before* you call the function, in other words, what in your program prevents this count? Peter -- http://www.boosten.org