Click here to Skip to main content
15,888,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Simple FTP Client Pin
Peter Weyzen1-Nov-07 16:24
Peter Weyzen1-Nov-07 16:24 
GeneralRe: Simple FTP Client Pin
dellthinker1-Nov-07 17:07
dellthinker1-Nov-07 17:07 
GeneralRe: Simple FTP Client Pin
Peter Weyzen1-Nov-07 20:30
Peter Weyzen1-Nov-07 20:30 
GeneralRe: Simple FTP Client Pin
dellthinker2-Nov-07 6:53
dellthinker2-Nov-07 6:53 
GeneralRe: Simple FTP Client Pin
Peter Weyzen2-Nov-07 7:32
Peter Weyzen2-Nov-07 7:32 
GeneralRe: Simple FTP Client Pin
Bram van Kampen2-Nov-07 3:22
Bram van Kampen2-Nov-07 3:22 
QuestionWizard 2000 Style Wizard Pin
Larry Mills Sr1-Nov-07 7:14
Larry Mills Sr1-Nov-07 7:14 
QuestionCan I pass through a variable number of arguments to another function? Pin
jp-mocs1-Nov-07 6:25
jp-mocs1-Nov-07 6:25 
Hi all...
My basic question is this: I have a function that accepts a variable number of arguments using '...' and I want to pass that argument list on to another routine without processing them. I figure this has to be able to be done, so... how?
Here is a bit more information... I am working in Visual Studio 2005, C++ in console mode. I have a class set up to handle the screen (cScreen) which has several instances of 'window' classes (cScreenWindow). The idea is to allow each individual window to take care of it's own maintenance. ONE of the windows will be defined in cScreen as the 'default print window' so any output sent to the screen that isn't targeted for a specific window will print in the default.
To allow formatted printing, I want to use printf styled commands. I already have cScreenWindow::cswPrintf(const char *format, ...) and that works well if I am sending the command from cScreen. But the main program can't access the windows directly, so there is a command cScreen::csPrint(const char *format) that basically just finds the default print window, and passes 'format' to it. Everything works like that so far...
Here is the tricky part... I want the main program to be able to call a function like cScreen::csPrintf(const char *format, ...) that in turn gets the default cScreenWindow::cswPrintf(const char *format, ...) and passes 'format' AND the variable argument '...' to it.
Here is some sample code:

main{}{
cScreen csr;

csr.csPrint("This works");
csr.csPrintf("how do I pass %s??", "this");
}

class cScreen{
public:
// vars
char printWin[20]; // the title of the default print window
// functions
cScreen *getWin(const char *winName); // this part works fine
void csPrint(const char *format); // this part works fine
void csPrintf(const char *format, ...); // how do I pass this???
};


void cScreen::csPrint(const char *format){
cScreenWindow tempWin = getWin(printWin);
tempWin.cswPrintf(format); // this part works fine
tempWin.cswPrintf("this %s too!!", "works"); // this part works fine
}

void cScreen::csPrintf(const char *format, ...){
cScreenWindow tempWin = getWin(printWin);
tempWin.cswPrintf(format, ?????????); // this is the question!!!
}

In cswPrintf, I use: 'va_list argp;' and parse through the arguments when I encounter a format token. I figure there must be a way to pass the arguments through using the va_list, but I'm not sure how.... anyone got any ideas???
My default (which can be done, but I'd rather not) is to allow csPrintf to go ahead and parse the string, and send a fully integrated string to cswPrintf, but that kind of defeats the whole purpose...

Thanx for any ideas/help!





=->Mocs<-=

AnswerRe: Can I pass through a variable number of arguments to another function? Pin
Luc Pattyn1-Nov-07 7:12
sitebuilderLuc Pattyn1-Nov-07 7:12 
AnswerRe: Can I pass through a variable number of arguments to another function? Pin
Chris Losinger1-Nov-07 7:50
professionalChris Losinger1-Nov-07 7:50 
GeneralRe: Can I pass through a variable number of arguments to another function? Pin
jp-mocs1-Nov-07 12:17
jp-mocs1-Nov-07 12:17 
GeneralRe: Can I pass through a variable number of arguments to another function? Pin
jp-mocs2-Nov-07 5:44
jp-mocs2-Nov-07 5:44 
QuestionOn selection a word in CEdit, which messages windows return? Pin
Gofur Halmurat1-Nov-07 6:19
Gofur Halmurat1-Nov-07 6:19 
AnswerRe: On selection a word in CEdit, which messages windows return? Pin
Maximilien1-Nov-07 6:23
Maximilien1-Nov-07 6:23 
GeneralRe: On selection a word in CEdit, which messages windows return? Pin
Gofur Halmurat1-Nov-07 6:34
Gofur Halmurat1-Nov-07 6:34 
AnswerRe: On selection a word in CEdit, which messages windows return? Pin
Mark Salsbery1-Nov-07 7:01
Mark Salsbery1-Nov-07 7:01 
GeneralRe: On selection a word in CEdit, which messages windows return? Pin
Gofur Halmurat1-Nov-07 7:24
Gofur Halmurat1-Nov-07 7:24 
GeneralRe: On selection a word in CEdit, which messages windows return? Pin
Mark Salsbery1-Nov-07 7:54
Mark Salsbery1-Nov-07 7:54 
GeneralRe: On selection a word in CEdit, which messages windows return? Pin
Gofur Halmurat1-Nov-07 9:29
Gofur Halmurat1-Nov-07 9:29 
GeneralRe: On selection a word in CEdit, which messages windows return? Pin
Mark Salsbery1-Nov-07 10:51
Mark Salsbery1-Nov-07 10:51 
QuestionBandwidth Monitor Pin
Alisdair Piercy1-Nov-07 5:25
Alisdair Piercy1-Nov-07 5:25 
AnswerRe: Bandwidth Monitor Pin
led mike1-Nov-07 6:06
led mike1-Nov-07 6:06 
GeneralRe: Bandwidth Monitor Pin
Alisdair Piercy1-Nov-07 6:10
Alisdair Piercy1-Nov-07 6:10 
GeneralRe: Bandwidth Monitor Pin
led mike1-Nov-07 6:36
led mike1-Nov-07 6:36 
Questionunresolved external ... CInvalidArgException Pin
bruccutler1-Nov-07 5:05
bruccutler1-Nov-07 5:05 

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.