Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] va_list

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Tue Apr 29, 2008 6:28 pm    Post subject: [C++] va_list Reply with quote

I just started C++ a few months ago. One concept I still don't understand is a function that takes an infinite number of arguments i.e. printf(). Then, I saw that it has something to do with va_list and va_arg. Can anyone explain to me how to use them?
Back to top
View user's profile Send private message
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Wed Apr 30, 2008 1:13 am    Post subject: Reply with quote

va_start/va_end, pretty straight-forward.

http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/MAN/va_start.htm
http://msdn.microsoft.com/en-us/library/kb57fad8.aspx
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Apr 30, 2008 10:32 am    Post subject: Reply with quote

Example:

Code:
void __cdecl DebugPrintF(const TCHAR *format, ...)

   TCHAR buf[4096], *p = buf; 
   va_list args; 

   va_start(args, format); 
   p += _vsntprintf_s(p, sizeof buf, sizeof buf-1, format, args);
   va_end(args); 

   while ( p > buf  &&  isspace(p[-1]) ) 
      *--p = '\0'; 

   *p++ = '\r'; 
   *p++ = '\n'; 
   *p   = '\0'; 

   OutputDebugString(buf); 
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites