Jump to content
  • Advertisement


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


passing va_list

This topic is 5406 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!