Jump to content
  • Advertisement


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


function parameters

This topic is 5530 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

Hello! To start with, Im playing with new things when it comes to functions (such as function pointers etc) and I would like to know how to get the parameters passed to a function when I do this: void Test(int x, ...) { } I call my test function with: Test(10, 20, 30, "hi"); But I only know that x is 10. How do I access the other variables? What is the name used for "..."? Sorry for posting this, I would have searched... but I dont know what to search for Thanks

Share this post

Link to post
Share on other sites
This is an example from an open source chess program that I have read in the past that uses it. Search for the va_ functions on the net, or look them up in a reference book. You need to include stdarg.h I believe. This function below basically is just a printf() wrapper. In the program, it needed fflush() to be called after each outputs, so the author chose to do it like this.

void VSendToWinboard(const char * szFmt, ...)
char aszBuf[1024];
va_list lpArgPtr;

va_start(lpArgPtr, szFmt);
vsprintf(aszBuf, szFmt, lpArgPtr);
printf("%s\n", aszBuf);

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!