| | |
variable arguments in C
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I think this should work, but i didn't test it, please do it yourself.
C Syntax (Toggle Plain Text)
#include <stdarg.h> void stringstofile (FILE *filehandle, ...) { va_list vargs; va_start (vargs, filehandle); while (va_arg (vargs, char *)) fputs (va_arg (vargs, char *), filehandle); va_end (vargs); }
Google first....
The ProgrammersTalk Community | Programming & Marketing | Buying & Selling Script
Hang out place of novice and intermediate programmers
Hang out place of novice and intermediate programmers
•
•
•
•
how can we pass variable arguments in any function of C?
C Syntax (Toggle Plain Text)
#include <stdio.h> int sum; int main() { sum = myfunction(5, 10); } int myfunction(int argument1, int argument2) { return argument1 + argument2; }
Code not tested, but see no reason why it shouldn't work.

Cheers.
GardCMS :: Open Source CMS :: Gardcms.org
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
1) What's the OP?
2) didn't want to over complicate things for the guy, as he seems to be just starting out in C, giving him a basic understanding of parameter passing would be more beneficial without talking to him about 'VA'.
That's my opinion anyway.
He asked for variable arguments -- the code you posted did nothing to answer that question. I don't know his experience and neither does anyone else. He must have at least some programming knowledge in order to even ask the question.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
OP = Original Poster. I thought OP was a pretty common term, but maybe I was wrong. That's what I get for using an anronym.
He asked for variable arguments -- the code you posted did nothing to answer that question. I don't know his experience and neither does anyone else. He must have at least some programming knowledge in order to even ask the question.
Haha, i thought he ment passing variable arguments.. as you can pass an array as a parameter (using pointers of course), so i thought he ment how do you pass a variable to a function.
Oh well
GardCMS :: Open Source CMS :: Gardcms.org
![]() |
Similar Threads
- Differences Between Java and C/C++ (C++)
- null pointer (VB.NET)
Other Threads in the C Forum
- Previous Thread: How to Send Data to IP address
- Next Thread: Convert MarkDown to MarkUP
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile creafecopyofanytypeoffileinc createcopyoffile createprocess() dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlogicaldrivestrin givemetehcodez grade graphics gtkwinlinux histogram homework i/o ide inches include infiniteloop initialization input intmain() iso keyboard km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft multi mysql oddnumber open opendocumentformat openwebfoundation overwrite pdf pointer pointers posix power program programming pyramidusingturboccodes radix read recursion recv recvblocked reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation testing threads unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi






