vlsidesign said:
I am not sure how to think about parentheses. It seems when they are
used alongside characters it indicates a function, like addTwoNums().
But is also is used to enforce which operators and operands are
evaluated first.
Can I think of the parentheses being used as "grouping" things
together or how should I think about them? Thanks
Several characters have multiple meanings in C source code,
depending on where they are used. Here are a few such:
. can be the decimal point in 3.14159, or the divider
between the name of a struct or union and one of its
elements in thing.field, or part of the ... ellipsis
that declares a variable-arguments function
/ can be the division operator operator in 3.2/x, or
part of a comment introducer /* or //, or part of a
comment terminator */
* can be the multiplication operator in x*y or x*=y, or
the pointer dereference operator in *ptr, or part of
a comment introducer or terminator
, can be the comma operator, or a separator in various
kinds of lists (function arguments, enum constants,
initializers, ...)
; can be the statement terminator, or a declaration
terminator, or the separator between clauses of `for'
() can surround a list of macro arguments, or a list of
function arguments, or a list of function parameter
declarations (in a couple of forms), or a sub-expression
within an expression, or assorted pieces of the `for',
`while', 'do-while', and `switch' statements
{} can surround blocks of statements and declarations,
or can delimit parts of various kinds of declarations,
or can surround groups and sub-groups of initializers
: can separate the name of a struct or union element from
its width in bits, or can separate a label from its
statement
E can be an identifier or part of an identifier as in
ERANGE, or can be part of a numeric literal like 2.7E26
& can be the address-of operator as in &thing, or the
bitwise AND operator as in flags&0x4 or byte&=0xFF,
or part of the logical AND operator as in x>0&&x<42
.... and so on, and so on. The meaning attached to a character
depends on the context in which it appears, and there is seldom
one single rule that covers all the possible contexts.