|
-
February 28th, 2012, 09:44 AM
#7
Re: My very first C program (Windows - console)
 Originally Posted by jlewand61
Understood. But with structured languages like this, you can get lost even with correct indenting. At least I can..... Do mean more verbose variable and function names?
Yeah. Given this variable I chose randomly, lwbbkpst, nobody would have any clue what it is or what it does. Give it a name that means something.
You don't line your braces up vertically, which I find annoying. Take this simple function,
Code:
void takeownCB ( TCHAR* takeownCBf ) {
// only display non-empty takeown output lines
if ( _tcslen ( takeownCBf ) > 1 ) {
_tprintf(_T("TAKEOWN %s"), takeownCBf);
}
return;
// end function
}
change the indentation
Code:
void takeownCB ( TCHAR* takeownCBf )
{
if ( _tcslen ( takeownCBf ) > 1 )
{
_tprintf(_T("TAKEOWN %s"), takeownCBf);
}
return;
}
if you line things up, it's really easy to see where one block, function, etc. starts and ends. Give your variables meaningful names, learn how to use indentation properly and lose 95% of your comments.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|