Re: var_args problems in C... any ideas?

Jas (matt@nospam.uts.edu.au)
Mon, 12 Dec 1994 17:46:52 +1000 (EST)

Paul Damien Mclachlan wrote this...
>
>
> OK... here's a toughie...
>
> OK... I'm trying to write a function that is close to scanf, but horribly more complex once you look at it. (I think so, anyway)
>
> consider:
>
> void interface( char *typelist, char *instring, void *function )
>
> where typelist is a scanf type string, eg "%c%d%s"
> instring is a list to scan from, eg "a14hello there"
> and function is a function to call. In the above example it would be:
>
> void function( char g, int num, char *str );
>
> see what I mean? I need a way to generate a var_args style list, without actually using var_args, because they are just used for reading varargs, not passing them, as far as I can tell.
>
> I'd preferably like a way to do it without having to consider each possible permutation of the typelist string, and I'd really like to be told it can be done in portable C... I could do it on a PC, with stack based passing using just a little hack - but t> hats not very portable - and I wouldn't have a clue how to do it so that it would work on ftoomsh anyway!
>
> btw... the actual use of this code is very good - this is a highly simplified example, but anyway :P
>
> I'd appreciate any help from all you clever ppl out there.... because I've spent a day on it and don't have a clue!
>
> Regards,
>
> Paul
>
>
have a look at lex. btw try making your lines < 80 chars wide. :)

Matt

--

Matthew Keenan Systems Programmer Information Technology Division University of Technology Sydney Australia

www: http://milliways.itd.uts.edu.au/~matt/ email: matt@nospam.uts.edu.au phone: +61 2 330 1390 "Don't murder a man who is about fax: +61 2 330 1999 to commit suicide." home: +61 2 416 5722 -- Machiavelli

GCV 2.1 GAT/M/CS d--(-+) H-- s++:-- g+ p? !au a-(?) w+++ v+ C+++$ UVS++++$ P+>+++ L- 3+++ E-(++) N++ K W--- M+ V-- -po+(+) Y+ t+ !5>++ jx R+ G? !tv b+++ D++ B e+ u--(**) h- f+(*) r n- !y