Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the (...) called in C and C++?

One of the uses of ... is to denote variadic entities in C and C++.

What is its name?

Is it classified as an operator or something else when used in that way?

Any other details regarding ...?

Edit: I know the purpose of .... I am asking about its name and classification, which I hope, is similar in both C and C++.

like image 660
Ardent Coder Avatar asked Jan 11 '20 17:01

Ardent Coder


People also ask

What is & symbol in C?

& means the address-of, you will see that in placeholders for functions to modify the parameter variable as in C, parameter variables are passed by value, using the ampersand means to pass by reference. * means the dereference of a pointer variable, meaning to get the value of that pointer variable.

What is this operator called ?:?

3. What is this operator called ?:? Explanation: In this operator, if the condition is true means, it will return the first operator, otherwise second operator.


2 Answers

It is one of the punctuators.

6.4.6  Punctuators Syntax punctuator:      one of  [    ]    (    )    {   }    .    ->              ++   --   &    *    +   -    ~    !              /    %    <<   >>   <   >    <=   >=    ==   !=   ^   |   &&   ||              ?    :    ;    ...              =    *=   /=   %=   +=  -=   <<=  >>=   &=   ^=   |=              ,    #    ##              <:   :>   <%   %>   %:   %:%: 

In the function declaration it is called the ellipsis.


Ellipsis is also used by some compiler C language extensions. Example - gcc switch/case range extension

const char *test(unsigned num) {     switch(num)     {         case 0 ... 9:             return "the value is in the 0 to 9 range";         case 10 ... 99:             return "the value is in the 10 to 99 range";         default:             return "out of tested range";     } } 

https://godbolt.org/z/YBLma-

like image 133
0___________ Avatar answered Sep 22 '22 20:09

0___________


The ... is referred to as an ellipsis both in English and in the C standard.

like image 37
Ahmed Masud Avatar answered Sep 19 '22 20:09

Ahmed Masud