I wiil not add anything to the earlier answers that well explained the fact that : is used to indicate bit-field members in struct declarations.
On the other hand, in C we have the ternary operator ? : which works in this way, for example:
int condition = 3 > 4;
char result1 = 'x', result2 = 'A';
char x = (condition)? result1 : result2;
- The ternary operator evaluates a
condition.
- If the
condition is true (non-zero value), then the expression result1 is evaluated.
- If the
condition is false (zero value), then the expression result2 is evaluated.
In other words, it's a short-hand for an if() sentence, with the advantage that can be used in expressions.
As you can see, the character : is part of the ternary operator ?:, but it's not an operator by its own, since it goes joint to the character ?.