65.9K
CodeProject is changing. Read more.
Home

Braces and brackets

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (26 votes)

Nov 15, 1999

CPOL
viewsIcon

1798399

downloadIcon

846

Options for placing braces

Options for Parentheses

Option 1: Spaces between inside and outside the parentheses. 

if ( something )
...

Option 2: Spaces outside parentheses, no space inside.

if (something)
...

Option 3: Spaces inside parentheses, no space outside.

if( something )
...

Option 4: No white space.

if(something)
...

Options for braces

Option 1: Braces starting on control line.

if (something) {
  // statements
}

Option 2: Braces starting on line under control line, non-indented.

if (something) 
{
    // statements
}

Option 3: Braces starting on line under control line, indented.

if (something) 
    {
    // statements
    }

Option 4: Braces starting on control line, closing brace indented.

if (something) {
    // statements
    }