Variable argument functions- how to?
-
Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ). Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good. Any idea of where i should start looking? Thanks!
-
Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ). Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good. Any idea of where i should start looking? Thanks!
You may just code a simple console (text-mode) application, and trace into printf( ... ).
Maxwell Chen
-
Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ). Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good. Any idea of where i should start looking? Thanks!
#include #include double average(int num, ...)
{
va_list arguments; //A place to store the list of arguments
va_start(arguments, num); //Initializing arguments to store all values
int sum=0; // passed in after num
for(int x=0; x
I'll write a suicide note on a hundred dollar bill - Dire Straits
-
#include #include double average(int num, ...)
{
va_list arguments; //A place to store the list of arguments
va_start(arguments, num); //Initializing arguments to store all values
int sum=0; // passed in after num
for(int x=0; x
I'll write a suicide note on a hundred dollar bill - Dire Straits