Difference between revisions of "Coding Style"

184 bytes added ,  16:45, 2 April 2012
m
(Created page with "= Coding style for C and C++ = 1. Function names: each word in function name should start with capital letter. No underscores. For example: '''CreateNewUser'''. Underscores a...")
 
Line 13: Line 13:
6. Opening { should be placed on next line without indentation, like below:
6. Opening { should be placed on next line without indentation, like below:


<syntaxhighlight lang="c">
   if (a < b)
   if (a < b)
   {
   {
       something();
       something();
   }
   }
</syntaxhighlight>


7. Operators and operands should be separated by spaces, like below:
7. Operators and operands should be separated by spaces, like below:


<syntaxhighlight lang="c">
   a = x + 20 / (y - z);
   a = x + 20 / (y - z);
</syntaxhighlight>
   
   
8. Function arguments should be separated by spaces, like below:
8. Function arguments should be separated by spaces, like below:
   
   
<syntaxhighlight lang="c">
   z = function(p1, p2, p3);
   z = function(p1, p2, p3);
</syntaxhighlight>
   
   
9. One-line comments should be placed with the same indentation level as code, like this:
9. One-line comments should be placed with the same indentation level as code, like this:
   
   
<syntaxhighlight lang="c">
   c = xxx();
   c = xxx();
   if (a)
   if (a)
Line 34: Line 41:
       func();
       func();
   }
   }
</syntaxhighlight>
   
   
10. Brackets after for and while operators may or may not be separated by spaces (I prefer not to separate them, but it's not a big problem IMHO).
10. Brackets after for and while operators may or may not be separated by spaces (I prefer not to separate them, but it's not a big problem IMHO).
683

edits