Click here to Skip to main content
13,557,860 members
Click here to Skip to main content
Add your own
alternative version

Tagged as



11 bookmarked
Posted 14 Nov 1999
Licenced CPOL

Braces and brackets

, 3 Nov 2000
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.

You may also be interested in...

Comments and Discussions

GeneralOld post Pin
mbaocha6-May-09 12:32
membermbaocha6-May-09 12:32 
GeneralRe: Old post Pin
Harsimran Singh (.NET)20-Jan-10 12:25
memberHarsimran Singh (.NET)20-Jan-10 12:25 
GeneralRe: Old post Pin
AlluvialDeposit2-May-13 1:23
professionalAlluvialDeposit2-May-13 1:23 
GeneralBalancing between disk usage & readability Pin
Anonymous1-Sep-01 3:10
memberAnonymous1-Sep-01 3:10 
GeneralRe: Balancing between disk usage & readability Pin
NebuGranny29-Mar-04 9:51
memberNebuGranny29-Mar-04 9:51 
GeneralRe: Balancing between disk usage & readability Pin
Derek Bartram22-Mar-08 11:26
memberDerek Bartram22-Mar-08 11:26 
QuestionHow about spaces Pin
AlexMarbus27-Feb-01 7:27
memberAlexMarbus27-Feb-01 7:27 
AnswerRe: How about spaces Pin
Jason Douglas2-Mar-01 3:38
memberJason Douglas2-Mar-01 3:38 
AnswerRe: How about spaces Pin
Anonymous2-Mar-01 6:05
memberAnonymous2-Mar-01 6:05 
GeneralRe: How about spaces Pin
James R. Twine4-Mar-01 7:51
memberJames R. Twine4-Mar-01 7:51 
AnswerRe: How about spaces Pin
Simon Hughes2-Apr-01 0:24
memberSimon Hughes2-Apr-01 0:24 
AnswerRe: How about spaces Pin
Yoko1-May-01 4:06
memberYoko1-May-01 4:06 
AnswerRe: How about spaces Pin
James Pullicino4-May-01 4:45
memberJames Pullicino4-May-01 4:45 

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

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

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