- I'd like to add a comment to the source code.
This is text that doesn't compile.
Instead it's intended as a note for the programmer,
a reminder, or just general information.
Insert a new line at the top of your source code file.
Type /*.
Traditional C comments start with the /*
character combination, and end with the */ characters.
The editor highlights all the text in the code,
which is now effectively one long comment,
because no ending comment characters have been written.
Type your name and the date.
Type */ to end the comment.
Comments aren't compiled, and you can prove it.
Save the changes, Build and Run, and the output is the same.
A second type of comment uses // at the start of a line.
You can use this comment to disable a statement in the code,
which happens a lot when you're hunting down bugs
or trying to fix something.
I'll comment out line six, the first PUT Statement.
Save, Build and Run.
See how the output doesn't appear?
That's because the compiler treated it like a comment.
If you'd like to restore the line, remove the // comment,
then save, Build and Run again.
Before closing this movie, I want you to view
the files created when you build a program in C.
Open a folder window to view the contents
of your exercise folder.
For each source code file you find an object code file.
It has the same name as the source code file,
but with a .o filename extension.
That's the file created by the compiler.
The object code file contains both the compiled source code,
as well as information from the header file.
The linker takes that object code file and mixes in
the C library file.
The result is a program file, which also has
the same name as the source code file.
In Windows you may see the filename extension .exe,
which means executable.
In other operating systems no extension is necessary.
The extension doesn't show up on this screen
because Windows is configured not to show
certain filename extensions.
The program file might also be given the name
a.exe or a.out.
That's the linker's default name.
Although in code blocks, the program's name
is the same as the source code file's name.