According to you, how do you indent your code and comments? how do you write comments?
e.g
/*Variable declaration*/
int i;
or
int i; /*Variable declaration*/
it's always useful to know the way other pple work. thx
According to you, how do you indent your code and comments? how do you write comments?
e.g
/*Variable declaration*/
int i;
or
int i; /*Variable declaration*/
it's always useful to know the way other pple work. thx
another thread....
it varies....
cause sometimes you write it like this and sometimes the other way round...
Why do u say : "another thread..."?
i just wanted to know what u thought was better i'm still a beginner and i want to know from pros like u.
It depends. Here's an example
[EDIT: I wrote the example too fast and forgot the semicolons]Code:... /* Attributes of Cats */ char name[8]; /* Name of the Cat */ int age; /* Age of cat*/ int weight; /* Weight of Cat */ ...
Last edited by kinghajj; 07-15-2003 at 12:42 PM.
What he meant by "another thread" was that this is another noobie thread. Don't feel to bad, though. I have a lot of them too.
The most important thing is to write decent comments.
Things like "variable declaration" and "name of cat" are not the type of thing you want to be commenting. This is simply because anyone with half a clue about C will know that a char array called "name" is an array for holding a name!
Document why your code does things, and if complexity requires it, document the how. Don't document the blindingly obvious.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
It's different, how to comment your code
you have to find your own way.....
comments are there, to make the code more readable.....
and "another thread"....
=> another funny thread
I don't laugh.... I find just the question funny....
>>It's different, how to comment your code
you have to find your own way....<<
Not when you're working in a team. A common understanding/style is a better approach, imo.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
My style also varies some, but in general:
A block comment before a block of code explaining what's about to happen, probably multiline comment
A post-line comment to explain what this line does or what the variable is for
int tramp; /* counts the number of hobos to date */
Post-line comments also at the end of if/for/while/switch structures
I will also mix /* */ and // in a program -- I'm not that much of a puristCode:} // end of if (a != 7) } // end of for lp2 } // end of if !done
oops, forgot the close code. at least I remembered the opening tag!
Last edited by WaltP; 07-16-2003 at 12:51 PM.
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
[QUOTE]
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
[/QUOTE]
Don't comment things that can be easily understood from the code. Remember, documentation has to be kept synchronized with the code itself. If code is clear, but the comments are out of date, then the programmer doing maintenance has to figure out if the comment is in fact out of date, or if the code is actually doing something more than meets the eye, and wastes time on that. Of course, if your code does do something more than meets the eye, it should be commented.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I indent my code like this
I think that most people find it a lot easier to read than those "other" ways.Code:int main() { char a,b,c,d; return 0; }
Comment as needed. When you're learning, you might want to comment stuff that you'd never consider commenting later. Just comment whatever you think might confuse you.
Away.
At uni, my lecturer makes us comment on every bit of code. i think he's doing this coz there's many students who've never done programming before. i just love programming!!! (though i get some probs with C)
I generally don't comment (for personal use) unless I feel that I might forget what the hell it is.
I usually write all the comments needed at the beginning
of a function so that it is more detailed and readable. However,
I'll add some comments next to some lines if I feel it is imp.
I also keep two versons (one without comments) so that the code is more readable You know, that actually helps sometimes.
I always use // instead of /* */ comments just because I find it looks better. Although it is a pain to have to take out twenty //'s when you would have just had to take out the /* */'s. :P
To error is human, to really foul things up requires a computer