Afficher un message
Vieux 06/04/2008, 08h25   #6
Jim Langston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Left brace on a single line -- Question

Bryan Parkoff wrote:
> I want to know the best practice to write on both C / C++ source
> codes. The best practice is to ensure readable. Should left brace be
> after function or if on the same line or next line.
>
> For example...
>
> void Test( void) {
> int a = 5;
> printf( "%d\n", a);
> }
>
> or...
>
> void Test( void)
> {
> int a = 5;
> printf( "%d\n", a);
> }
>
> It applies to if. For example...
>
> if (a == 5) {
> printf( "%d\n", a);
> printf( "End...\n";
> }
>
> or...
>
> if (a == 5)
> {
> printf( "%d\n", a);
> printf( "End...\n";
> }


Personal choice. Whatever you are comfortable with. When working with
existing code it's probably a good idea to stick with the formatting it
uses.

Personally, I use the 2nd format of { on it's own line. My IDE prefers that
format too and some auto formatting gets screwed up if it isn't in that
format.


--
Jim Langston
tazmaster@rocketmail.com


  Réponse avec citation
 
Page generated in 0,04967 seconds with 9 queries