does anyone do this?
i think it looks much more solidCode:
if( 1 )
{
x++;
}else{ //same line
x--;
}
Printable View
does anyone do this?
i think it looks much more solidCode:
if( 1 )
{
x++;
}else{ //same line
x--;
}
I have a lot of odd rules, however generally sticking to number 2 (do try and catch don't actually have that high a ratio in my code really). Sometimes I inline small statements following an if too, just if putting it on a newline puts it out of place. Also, 1-2 space indentation is killer, I don't know how some people swear by it. I need like 4-6 spaces per tab at least.Code:int main()
{
try {
while(condition)
{
if(stuff)
{
dothings;
dothings;
}
else
meh();
}
}
catch(Exception e) {
e.what();
}
}
void meh()
{
do {
int nRet = thingz();
if(nRet == -1) break;
} while(nRet != 0);
}
I accidentally voted 3, but use 2.
>.<
Style #2 (BSD/Allman) is obiously the only correct coding style, since it's the one I use.
I use Allman/BSD, like a lot of the rest of you. It just seems much more clear and easier to read, especially when debugging.
I see K&R used alot in tutorials and such, but I never liked it...
The same can be said about Whitesmith :(Quote:
Originally Posted by Zach L.
is (usually) the same asCode:FILE *fp = fopen("out", "wt");
The latter uses the system default, which is usually 't' (text mode) but can be 'b' (binary mode). You can open a file in binary mode, too.Code:FILE *fp = fopen("out", "w");
So yes, t is a valid mode. :)Code:FILE *fp = fopen("out", "wb");
Umm... are you sure that's in the right thread?
EDIT: Nevermind... I didn't read the whole thread.
I don't know what is most common, but I also normally use style 1.