C: More Operators and Arrays - Commenting on Your Code
(Page 5 of 5 )
Now that you know how to work with arrays and operators, you will be able to make larger programs. And often when we make larger programs, things can go wrong. There it is, six months after you have released your program and BAM! some wacky user has found a way to use it in some way you didn't intend. So now you have to look through your code and try to figure out what you were thinking six months ago. It's worse if you are looking at someone else's code and trying to fix it. In C, and every other language, you are able to comment, which is text that the computer ignores or can't even see, that lets you/other programmers know what you were trying to achieve with parts of your code.
To write a single line comment you use the //, like so:
printf("I like to eat monkey stew!"); //print some stupid text
To do multi-line comments:
/*This code below
will print some stupid text*/
printf("I like to eat monkey stew!"); //print some stupid text
When the computer sees the // it ignores the text following it on that line. When the computer sees /* it ignores all text after it until it sees the */.
That's it for this episode. Join us next time when I discuss Statements and MAYBE Loops in C.
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |