To share this page click on the buttons below;
Comments
Comments a free space in the code where we can put explanations and description about the code.
C language only supports one kind of comments: to make a comment you put the comment content between /*
(that signals the start of your comment) and */
(which is the end of the comment).
Everything is found in the middle of these 2 markers is simply ignored by the compiler, comments are for human beings readers, the compiler does not use them at all.
It is difficult to define the concept of a proper commented code: it depends form your personal taste, but I would suggest that more is better than less (although sometimes being too much verbose might result desultory). Comments are important to remember what you did and why. You will discover soon that comments are important in particular for you.
Misuse of comments
There is a misuse that people tends to do of comments: very often people "comments out" code because they want to keep it without compiling it. It is quite common: you are trying different solutions so you comment out the previous version of code (because you want to remember the previous solution) and then you write the new one and so on. There is no problem if this is done during development but it has to be avoided when you finalize your code. There are a couple of good reasons:
- having a lot of actual code "commented" makes the code unreadable and messy
- commenting code does not give to the reader the clear understanding of why the code is not used and why is there (to explain that you would probably need a comment!).
To share this page click on the buttons below;