Click here to Skip to main content
15,502,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with calculating percentage in C Pin
Victor Nijegorodov20-Mar-22 8:42
Victor Nijegorodov20-Mar-22 8:42 
GeneralRe: Help with calculating percentage in C Pin
ForNow20-Mar-22 10:02
ForNow20-Mar-22 10:02 
QuestionHow to pass pointers and process them using ellipsis ? Pin
Member 1496877118-Mar-22 16:23
Member 1496877118-Mar-22 16:23 
AnswerRe: How to pass pointers and process them using ellipsis ? Pin
Richard MacCutchan19-Mar-22 0:08
mveRichard MacCutchan19-Mar-22 0:08 
GeneralRe: How to pass pointers and process them using ellipsis ? Pin
Member 1496877119-Mar-22 5:06
Member 1496877119-Mar-22 5:06 
GeneralRe: How to pass pointers and process them using ellipsis ? Pin
k505419-Mar-22 6:01
mvek505419-Mar-22 6:01 
GeneralRe: How to pass pointers and process them using ellipsis ? Pin
Member 1496877119-Mar-22 9:44
Member 1496877119-Mar-22 9:44 
GeneralRe: How to pass pointers and process them using ellipsis ? Pin
k505419-Mar-22 13:00
mvek505419-Mar-22 13:00 
It's pretty straight forward, really. When you use the va_arg macro, the second argument is the received objects type. So, to receive a pointer to a type, you use va_arg(args, Obj*) where Obj is some object type - e.g. class, int, double, struct, etc. Here's a short working example:
C++
#include <cstdarg>
#include <iostream>

struct S {
    int data;
    S(int d) : data(d) {}
};

void f(size_t n, ...)
{
    va_list args;
    va_start(args, n);
    for(size_t i = 0; i < n; ++i) {
        S* ptr = va_arg(args, S*);
        std::cout << ptr->data << '\n';
    }
}

int main()
{
    S item1(1); 
    S item2(2);
    S item3(3); 

    f(3, &item1, &item2, &item3);
}
Keep Calm and Carry On

GeneralRe: How to pass pointers and process them using ellipsis ? Pin
Richard MacCutchan19-Mar-22 7:11
mveRichard MacCutchan19-Mar-22 7:11 
Questionworking with pointers Pin
Calin Negru17-Mar-22 22:48
Calin Negru17-Mar-22 22:48 
AnswerRe: working with pointers Pin
Victor Nijegorodov18-Mar-22 0:16
Victor Nijegorodov18-Mar-22 0:16 
GeneralRe: working with pointers Pin
Calin Negru18-Mar-22 1:12
Calin Negru18-Mar-22 1:12 
GeneralRe: working with pointers Pin
Victor Nijegorodov18-Mar-22 2:39
Victor Nijegorodov18-Mar-22 2:39 
GeneralRe: working with pointers Pin
Calin Negru18-Mar-22 11:20
Calin Negru18-Mar-22 11:20 
Generalgoing a bit further: working with pointers Pin
Calin Negru20-Mar-22 8:47
Calin Negru20-Mar-22 8:47 
AnswerRe: working with pointers Pin
Mircea Neacsu18-Mar-22 11:19
mvaMircea Neacsu18-Mar-22 11:19 
QuestionRe: working with pointers Pin
David Crow21-Mar-22 4:16
David Crow21-Mar-22 4:16 
AnswerRe: working with pointers Pin
Calin Negru21-Mar-22 6:15
Calin Negru21-Mar-22 6:15 
QuestionCode to Figure out x,y cords for CDC::Pie inside an CDC::Ellipse given % Pin
ForNow13-Mar-22 10:37
ForNow13-Mar-22 10:37 
AnswerRe: Code to Figure out x,y cords for CDC::Pie inside an CDC::Ellipse given % Pin
Mircea Neacsu14-Mar-22 17:41
mvaMircea Neacsu14-Mar-22 17:41 
GeneralRe: Code to Figure out x,y cords for CDC::Pie inside an CDC::Ellipse given % Pin
ForNow15-Mar-22 6:01
ForNow15-Mar-22 6:01 
QuestionIPv6 address compression code using vc++ Pin
Member 1252773510-Mar-22 18:12
Member 1252773510-Mar-22 18:12 
AnswerRe: IPv6 address compression code using vc++ Pin
Victor Nijegorodov10-Mar-22 22:06
Victor Nijegorodov10-Mar-22 22:06 
QuestionQuestions about EM_SETWORDBREAKPROC message and EDITWORDBREAKPROCA function Pin
ForNow10-Mar-22 7:02
ForNow10-Mar-22 7:02 
AnswerRe: Questions about EM_SETWORDBREAKPROC message and EDITWORDBREAKPROCA function Pin
RedDk10-Mar-22 9:22
RedDk10-Mar-22 9:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.