I dunno. I would say a balance is important for any coding style. I would write that like this
Code:ptr = static_cast<int*> (realloc(ptr, sizeof(*ptr)));
Printable View
> For nuances for if, else and such I use tabs. Imho tabs are much more easy to write for me (using visual studio).
> It`s also more easy to change the nuances if you use tabs (in case of removing one of multiple ifs for example)
1. If you post code to a forum / mailing list, the result is almost always "what we get is NOT what you see". This is even more true if you've set the IDE to be something other than 8 spaces.
2. The IDE is smart enough to figure out indent. You can for example highlight a whole block of code and press tab to indent one level and shift-tab to undent one level.
Coupled with auto indent as you type, most of the time it isn't a problem at all.
> Is there already some program which can change the style of the source? Like 1) to 2) would be awesome.
Loads of them
http://clusty.com/search?query=code+...Mozilla-search
http://clusty.com/search?query=code+...Mozilla-search
If you have cygwin / Linux, then
man indent
or
info indent
> Which one does he want to see? Cater to him, because he's giving the grade.
Absolutely.
The first style is that of whoever is giving the marks / writing the pay cheque.
I have two styles.....
The style I use at work. I write assuming someone will have to fix the bugs in the code a few months/years down the track (train pun...).
I want to make my intent as clear as possible, the code as readable as I can and so (hopefully) make the fix easier. I even put braces around single lines of code. I use 'allman'.
The style I use when I write code that _only_ I will read again. I write it as fast as possible with few comments and no spaces.