Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
C: Passing an unknown number of parameters and pass them on

 
Post new topic   Reply to topic Printable version
 View previous topic  returning array of strings in c++ Post :: Post casting  View next topic  
Author Message
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Wed Jan 21, 2009 12:52 pm    Post subject: C: Passing an unknown number of parameters and pass them on Reply to topic Reply with quote

I'm talking about some printf() style thing... Actually, I just want a function that receives some stuff, including a formatted string that will do some stuff, then do an actual printf with the parameters. So I don't even need to use those parameters, I'd just need to pass them back to the printf...

How would I do that?

I saw the printf header is declared like
Code: Show/Hide
printf(const char *, ...);

I'm guessing I can do that to my functions too, but in the definition of the function, how do I 'receive' those ... and how could I throw them back in the printf?


No big deal if it's not possible, and if the solution involves like 100 lines of code, forget it tongue.gif

This is C, not C++ too.
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Jan 21, 2009 1:29 pm    Post subject: Reply to topic Reply with quote

Found this on google for variable arguments: http://www.cprogramming.com/tutorial/lesson17.html

Looks pretty simple, though I've not personally used it.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Wed Jan 21, 2009 2:52 pm    Post subject: Reply to topic Reply with quote

Thanks... that helped; though I found the solution to my particular problem elsewhere

Code: Show/Hide

int my_printf(char* fmt, ...)
{
   int r;
   va_list args;
   va_start(args, fmt);
   r = vprintf(fmt, args);
   va_end(args);

   return r;

}
Back to top
View users profile Send private message Add User to Ignore List
Quan Chi2
Member of "Sexy Teenagers that Code" Group
Member of


Age:33
Gender:Gender:Male
Joined: Mar 25 2005
Posts: 860
Location: NYC
Offline

PostPosted: Sat Jan 24, 2009 3:11 am    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
Found this on google for variable arguments: http://www.cprogramming.com/tutorial/lesson17.html

Looks pretty simple, though I've not personally used it.


Ah... You beat me to it, Brain. tongue.gif I was reading that in school with a friend.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can 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 can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 628 page(s) served in previous 5 minutes.

phpBB Created this page in 0.460388 seconds : 29 queries executed (93.0%): GZIP compression disabled