home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!mcsun!sunic!ugle.unit.no!bjornw
- From: bjornw@colargol.edb.tih.no (Bjoern Wennberg)
- Subject: Variable argument list question
- Message-ID: <1992Dec15.182906.25072@ugle.unit.no>
- Sender: news@ugle.unit.no (NetNews Administrator)
- Organization: Colargol, Trondheim College of Engineering
- X-Newsreader: TIN [version 1.1 PL8]
- Date: Tue, 15 Dec 92 18:29:06 GMT
- Lines: 43
-
- Hi!
-
- I am trying to make a function that
- 1. Has an variable argument list
- 2. Manipulates the arguments that the argument list points to
-
-
- Here is an example which illustrates the problem:
-
- int main(void)
- {
- char *flag;
- func(flag);
- /* flag == "test" */
- }
-
- void func(...)
- {
- va_list args;
- va_start(args, "%s");
-
- va_arg(args, char *);
-
- /* allocate space for 'flag' by using 'args' */
- /* manipulate 'flag' by using 'args' */
-
- /* *args = new char[10]; doesn't work*/
- /* args = new char[10]; doesn't work*/
- /* memcpy() / strcpy() and friends doesn't work */
-
- /*
- * debugger show me that 'args' points to the same address as 'flag'
- * does. But I cannot insert anything inside this address.
- */
- va_end(args);
- }
-
- Any comments are welcome.
-
- bjornw>
- --
- bjornw@edb.tih.no Bjoern Wennberg Trondheim College of Engeneering
-
-