Click here to Skip to main content
Click here to Skip to main content

Tagged as

Braces and brackets

, 3 Nov 2000 CPOL
Rate this:
Please Sign up or sign in to vote.
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.


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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chris Maunder
Founder CodeProject
Canada Canada
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

GeneralOld post Pinmembermbaocha6-May-09 13:32 
GeneralRe: Old post PinmemberHarsimran Singh (.NET)20-Jan-10 13:25 
GeneralRe: Old post PinprofessionalAlluvialDeposit2-May-13 2:23 
GeneralBalancing between disk usage & readability PinmemberAnonymous1-Sep-01 4:10 
GeneralRe: Balancing between disk usage & readability PinmemberNebuGranny29-Mar-04 10:51 
GeneralRe: Balancing between disk usage & readability PinmemberDerek Bartram22-Mar-08 12:26 
QuestionHow about spaces PinmemberAlexMarbus27-Feb-01 8:27 
AnswerRe: How about spaces PinmemberJason Douglas2-Mar-01 4:38 
AnswerRe: How about spaces PinmemberAnonymous2-Mar-01 7:05 
GeneralRe: How about spaces PinmemberJames R. Twine4-Mar-01 8:51 
AnswerRe: How about spaces PinmemberSimon Hughes2-Apr-01 1:24 
AnswerRe: How about spaces PinmemberYoko1-May-01 5:06 
AnswerRe: How about spaces PinmemberJames Pullicino4-May-01 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 4 Nov 2000
Article Copyright 1999 by Chris Maunder
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid