top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How many variables can be passed in the argument list of a function in C?

+2 votes
414 views
How many variables can be passed in the argument list of a function in C?
posted May 2, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Whenever a function is declared to have an indeterminate number of arguments, in place of the last argument you should place an ellipsis (which looks like '...'), so, int a_function ( int x, ... ); would tell the compiler the function should accept however many arguments that the programmer uses, as long as it is equal to at least one, the one being the first, x.

int a_function ( int x, ... )
{
    va_list a_list;
    va_start( a_list, x );
}
answer May 3, 2015 by Amit Kumar Pandey
Similar Questions
+2 votes

How many parameters can we pass as argument in function? Is there any limit ?
If yes , Please explain the reason.

+4 votes

Means, at the time of calling the function , local variable get memory first OR argument ?

+2 votes

I know of "select()" which works using file descriptors.

However I want similar functionality to "select()" but for a simple function that returns an int.

So suppose, there's "int calculate_magic()" function and I want to allow it to work for 2 seconds, if it takes longer than that I want to move on.

If "calculate_magic()" wrote its answer to a file descriptor I could use "select()" but how to do it for the case I mentioned?

I need something like this for a simple game implementation where the player is allowed a maximum time to make a decision about their next move.
I
was hoping I can get something without having to deal with threads, etc.

...