| | |
variable arguments in C
![]() |
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 |
* adobe ansi api array asterisks binarysearch calculate centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory feet fflush fgets file fork forloop frequency function givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram i/o inches infiniteloop input intmain() iso kernel keyboard km linked linkedlist linux linuxsegmentationfault list locate looping loopinsideloop. lowest match microsoft mqqueue mysql number oddnumber odf open opendocumentformat owf pattern pdf performance posix probleminc process program programming radix recv recvblocked repetition research reversing scanf scheduling segmentationfault send sequential socket socketprograming stack standard string systemcall threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi






