Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


passing va_list

This topic is 5318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to write a function that takes variable parameters like printf and attempts to pass them on to printf. The function right now just passes the va_list on to printf. Here is my code:
#include <iostream>
#include <stdarg.h>


void print(int type,char *txt,...)
	va_list args;

int main()
	int n=-50;
	return 0;
It does nothing now, but later sprintf will be used to decide where to put it based on the type. My problem is that it returns -1073742616. It returns the same value every time, even after code changes and recompiles. When I change it to printf and remove the DEBUG arguement, it gives -50 as expected. Am I passing the arguement list wrong?

Share this post

Link to post
Share on other sites
Use vprintf, not printf.

vprintf( txt, args );

Similarly, use vsprintf for putting it in a string:

vsprintf( str, txt, args );

~CGameProgrammer( );

Screenshots of your games or desktop captures -- Upload up to four 1600x1200 screenshots of your projects, registration optional. View all existing ones in the archives..

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!