Hi there!)
Guys please tell me - where can I see the realization (or custom realization) of fprintf in C++ ?
I'm especially interesed in working with no fixed number of passed parameters.
I need to made somethings like fpintf() by myself but i don't know how....

big thanks in advance)

Recommended Answers

All 5 Replies

Look up
va_start,
va_list,
va_arg,
va_end

guys tell me - how does fprintf() get know - when the list of parameters is ended ?
we not pass Null or 0 parameter as last one. - but everything works.

how does fprintf() get know - when the list of parameters is ended ?

It relies on the format string for this information. That's why nothing bad happens if you provide more arguments than the format string uses, but it's undefined behavior if you provide fewer.

It relies on the format string for this information. That's why nothing bad happens if you provide more arguments than the format string uses, but it's undefined behavior if you provide fewer

thanks deceptikon ! i've understood you))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.