Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sander Aerts

Passing unknown number of options

This topic is 5303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All, When you create a function with a unknown length of parameters you can use ..., for example: void foo(char *bla, ...) But now i want to pass all ... vars 2 printf how can i do this?

Share this post


Link to post
Share on other sites
Advertisement
Should we warn him that non-POD types cannot be passed to such functions, or should we let him discover it all by himself ?


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites
Hi All,

I have it working with the following code :

va_start(arglist, information);
vsprintf(buffer1, information, arglist);
va_end(arglist);
strcpy(buffer2, "\t/*\t");
strcat(buffer2, buffer1);
/* Calculate needed end tabs */
tabs = TAB - (strlen(buffer2) - (strlen(buffer2) % 8)) / 8; if (tabs > 0)
for (cc = 0; cc < tabs; cc++)
strcat(buffer2, "\t");
strcat(buffer2, "*/\n");
print(buffer2); /* Custom functions for printing 2 a buffer */
free(buffer1);
free(buffer2);

--

Thx for the information!

------

With kind regards,

Sander Aerts aka DrSnugels

Crap
---------------------------
mov ax, 013h; int 10h; mov ax, 0xa000h;
mov es, ax; mov di, 3360; mov al, 15;
stosb; mov ax, 0002h; int 21h;
mov ax, 03h; int 10h;

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!