How to use comments and read compiler errors

Write comments

Use // through the end of a line or /* ... */ across lines. Block comments do not nest.

// Convert hours to seconds.
int seconds = hours * 60 * 60;

/* A short explanation
   may span lines. */

Comment the reason

Explain constraints, units, or a non-obvious choice rather than translating every statement into English. Remove stale comments when behavior changes.

Read the first diagnostic

Start with the first error and its file, line, and column. One missing semicolon or brace can produce many later messages.

broken.c:6:5: error: expected ';' after expression
    printf("done\n")
                    ^

Enable and resolve warnings

Compile with warning flags on every build. Never silence a pointer, format-string, conversion, or bounds warning without understanding why it is safe.

gcc -std=c17 -Wall -Wextra -Wpedantic source.c -o program