| | |
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
Views: 5156 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for C
#include * ansi array arrays asterisks binarysearch calculate changingto char cm command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic execv fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics gtkwinlinux hacking hardware histogram homework inches include incrementoperators input iso kernel keyboard km lazy linked linkedlist linux list lists locate logical_drives looping loopinsideloop. lowest matrix microsoft motherboard mqqueue number opendocumentformat opensource overwrite owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential socket socketprograming spoonfeeding standard string structures student systemcall testing threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






