home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!darwin.sura.net!wupost!cs.utexas.edu!sun-barr!ames!agate!linus!linus.mitre.org!el_padre.mitre.org!bdickens
- From: bdickens@el_padre.mitre.org (Brian Dickens)
- Subject: Variable argument question
- Message-ID: <1992Jul22.135609.17393@linus.mitre.org>
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: el_padre.mitre.org
- Organization: The MITRE Corporation, Bedford, MA 01730
- Date: Wed, 22 Jul 1992 13:56:09 GMT
- Lines: 24
-
- I am trying to write code that calls a function whose parameters it knows, but are different every time.
- The data type and size information is stored in an array. To put it perhaps more clearly:
-
- #define INT 0
- #define FLOAT 1
- #define CHAR 2
-
- char *dataptr;
- int parameters[10] = { INT, 1, FLOAT, 2, FLOAT, 1, CHAR, 10, INT, 1 };
-
- From this, I want to generate:
-
- functioncall( (int*)(dataptr), (float*)(dataptr+=sizeof(int)),
- (float*)(dataptr+=sizeof(float[2])), (char*)(dataptr+=sizeof(float),
- (int*)(dataptr+=sizeof(char[10]));
-
- The array changes, though. With frequency. And the function being called changes as well...
-
- Is there any way to do this with argument lists/etc? I am using standard C. Thanks in advance for any help.
-
- <<<?>>> bdickens@elara.mitre.org <<<!>>>
-
- Hope this makes sense...
-
-