C Guide – Comments


Comments are very important in programming. Could you imagine what you would do if you wrote a program that was hundreds of lines long, and you forgot what a certain function did? or what that variable was for?!

 

What is a Comment?

SO, what is a comment I hear you cry? A comment is a line (or lines) of code – text to be honest – that will not be read by the compiler when you run the code. So you could comment out a whole function, and the compiler would act as if that function didn’t even exist at all! (poor function 😦 )

 

Comments – The Ways

In C there are two ways – to my knowledge… – of creating comments in a C program. The first way is this:

Comments

So here, if you place β€˜//’ at the beginning of a line in C, then the rest of the line we become a comment!

 

The second way to create a comment is like shown below:

Comments

Here, if you place β€˜/*’ at the beginning of a line, and β€˜*/’ at the end of the line you want to be a comment, then that whole line will turn into a comment.

Even better, if you do what the image shows above, you can place β€˜/*’ on one line and β€˜*/’ on another line, and you can comment out 2+ lines at once! This is miles better than comments out 100 lines by typing 100 β€˜//’ πŸ˜€
All you need is an β€˜/*’ on line 1, and an β€˜*/’ on line 100, and wallah!

 

Next is Variables, these are vital if you really want to do some neat stuff with your code πŸ˜€

Advertisements

About Badgerati
Computer Scientist, Games Developer, and DevOps Engineer. Fantasy and Sci-fi book lover, also founder of Cadaeic Studios.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: