Raised This Month: $ Target: $400
 0% 

C++ help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 10-27-2013 , 14:07   C++ help
Reply With Quote #1

Hello alliedmodders!


Need some c++ help here, i dont know how to search this ( how to but that in the words what im doing )

Anyway, i need to work with marco so here is a example
PHP Code:
#define myfunction(p1,p2) oldfunciont(p1,p2) 
this thing allow me to replace old function name with the new one.
Now when i want to replace sprintf kind of functions, there comes some problems because it has "..."
PHP Code:
int sprintf char str, const char format, ... ) 
Can someone give me an example here how can i do this
PHP Code:
#define cformat(str,fstr,?) sprintf(str,fstr,?) 
.Dare Devil. is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 10-27-2013 , 14:20   Re: C++ help
Reply With Quote #2

I put __VA_ARGS__ in the oldfunction last param and it worked
PHP Code:
#define cformat(str,fstr,...) sprintf(str,fstr, __VA_ARGS__) 
Uh, well ... that was easy .
.Dare Devil. is offline
BAILOPAN
Join Date: Jan 2004
Old 10-27-2013 , 14:44   Re: C++ help
Reply With Quote #3

Use snprintf if you can, you risk buffer overflow otherwise - it's like passing 99999999 into format().
__________________
egg
BAILOPAN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode