void fr(char *f, ...)

hello guys . my question is : how can i work with argument in body of

void fr(char *f, ...)
{
// ?!!! i want work with ... argument but how ?!
}
You work with it using its name, which is f.
closed account (z05DSL3A)
ahura24,

do you mean something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cassert>
#include <cstdarg>
using namespace std;

int max(unsigned count, ...)
{
    assert(count > 0);
   
    va_list arguments;
    
    va_start(arguments, count);

    int result = va_arg(arguments, int);
    
    while(--count > 0)
    {
        int arg = va_arg(arguments, int);
        if (arg > result)
            result = arg;
    }
    
    va_end(arguments);

    return result;
}


int main() 
{
    int a(56), b(8), c(66),d(14);
    cout << max(4 /*number of parameters passed */, a, b, c, d) <<endl;
    
    return 0;
}
Topic archived. No new replies allowed.