From owner-freebsd-questions@FreeBSD.ORG Sun May 4 07:40:44 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 DA83E106564A for ; Sun, 4 May 2008 07:40:44 +0000 (UTC) (envelope-from unga888@yahoo.com) Received: from web57014.mail.re3.yahoo.com (web57014.mail.re3.yahoo.com [66.196.97.118]) by mx1.freebsd.org (Postfix) with SMTP id 7C7458FC17 for ; Sun, 4 May 2008 07:40:44 +0000 (UTC) (envelope-from unga888@yahoo.com) Received: (qmail 36286 invoked by uid 60001); 4 May 2008 07:40:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=s7n/IIfK1D4fs6xBI3cqjUAu+KDYYpf8rri1vBkSOC3YqCG+Fmju6uKOXn/dPfOCU+QnY4PIlPhkAplOpZvcuIEN1KXpeAVCXFc+d0OSCSUH3+2EAcqssLFJIKWp/EZSFboZpC/0Qy1TMvyTBvFFIauqqvAIvJu2AbGE4XrQJOA=; X-YMail-OSG: eQHAVnYVM1kyp5QHpgxS4T0AybwXQYcSzh6Z.LyVMDz1p9wdEhxtP4cPt7x0f4n3uTLXxizeBrsN57IGw2TgMj0leVyWvkiQu8o.AK8nE.EgHmWd3WOo7P9k3e0- Received: from [220.255.7.247] by web57014.mail.re3.yahoo.com via HTTP; Sun, 04 May 2008 00:40:43 PDT Date: Sun, 4 May 2008 00:40:43 -0700 (PDT) From: Unga To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <336540.36159.qm@web57014.mail.re3.yahoo.com> Subject: 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 07:40:44 -0000 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. How do you guys implement variable arg function such as f(str1, str2, str3, ..., strN)? Sorry for the sightly off topic question, the only relevance is I'm programming this app on FreeBSD 7.0 :) Many thanks in advance. Kind regards Unga ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ