954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

arguments in function

im not sure exactly what its called or how to use it.. but im guessing its used to pass over variables as arguments to a function, ive only seen it in functions with this added after it: ,...) somewaht similar to the code below..

int myfunc(char *data,const char *data2<strong>,...</strong>)
{
    ....
    return 0;
}

int main(void)
{
    char varhold[21];
    memset(varhold,0,sizeof(varhold));
    sprintf(varhold,"bob");
    myfunc("hey","hi %s",varhold);
    return 0;
}

can someone tell me what it is? how to use it? examples?

osean
Newbie Poster
14 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

im not sure exactly what its called or how to use it.. but im guessing its used to pass over variables as arguments to a function, ive only seen it in functions with this added after it: ,...) somewaht similar to the code below..

int myfunc(char *data,const char *data2<strong>,...</strong>)
{
    ....
    return 0;
}

int main(void)
{
    char varhold[21];
    memset(varhold,0,sizeof(varhold));
    sprintf(varhold,"bob");
    myfunc("hey","hi %s",varhold);
    return 0;
}

can someone tell me what it is? how to use it? examples?

The 3 dots "..." are not part of C or C++. Presumably whichever book you are using is obscuring some of the function's definition... It might mean that whatever would be behind those 3 dots is unimportant to the example in your book, but that is just as guess

Bench
Posting Pro
577 posts since Feb 2006
Reputation Points: 307
Solved Threads: 63
 

i am not reading any book, its part of the actual source in several opensource applications i have seen.. i am specifically taking it from Unreal 3.1, and if i dont have those three dots within the function it wont compile.. im just wondering what they do

osean
Newbie Poster
14 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

It tells that function is variable argument function.

SpS
Posting Pro
599 posts since Aug 2005
Reputation Points: 70
Solved Threads: 32
 

sunnypalsingh hit it right on the dot, thanks!
after searching google for a minute or so i found http://www.cprogramming.com/tutorial/c/lesson17.html (i probably should of checked there anyway before posting) which gives a bit of information on using argument lists in functions if anyone reading this cares or wants to know.

osean
Newbie Poster
14 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You