How do I deliver all the factors I received for

Asked 2 years ago, Updated 2 years ago, 96 views

If you have any idea what to do to hand over the factors you received to other functions in a function that receives multiple factors using...

void format_string(char *msg, ...);

void debug_print(int dbg_lvl, char * msg, ...) {
    To hand over all the factors received in format_string(msg,...);/*...? */
    fprintf(stdout, msg);
 }

c varargs

2022-09-22 11:42

1 Answers

From C

format_string(char *msg, ...)

In this way, you can't write a function that has only variable factors.

Because before the '...' parameter comes out, you have to have a parameter that tells you how many variable factors there are.

A call can only be made by msg in a function, but this function has no way of knowing how many variable factors there are, so you have to put a parameter in the format_string that tells you how many factors there are.

void format_string (int argc, char *msg, ...) and then

format_string(strcnt(msg), msg); 

You can call to .

If you don't understand, it would be helpful to find out why the main function's factors are int argc, char** argv.


2022-09-22 11:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.