how can we pass variable arguments in any function of C?
hitesh_mathpal
0
Newbie Poster
Recommended Answers
Jump to PostI think this should work, but i didn't test it, please do it yourself.
#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); }
Jump to PostGoogle first....
Jump to Posthow can we pass variable arguments in any function of C?
Simply to answer your question.
#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 …
All 13 Replies
Narue
5,707
Bad Cop
Team Colleague
TkTkorrovi
69
Junior Poster
ProgrammersTalk
11
Junior Poster in Training
dr4g
25
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
dr4g
25
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
hitesh_mathpal
0
Newbie Poster
dr4g
25
Junior Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
TkTkorrovi
69
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.