Use a good C style to format your source code files

A good C style of of the source code you write represents you. You will be judged by other people by the way your source code looks. Always try to write beautiful code.

There are many possible C styles. We recommend one that is well documented and comes with a Perl script for checking. The script does not catch everything but is pretty good.

The recommended C style is used for the Oracle Solaris operating system source code and is explained in a short (~20 pages) nicely formatted document: C Style and Coding Standards for SunOS.

The cstyle.pl for verification.

$ chmod u+x cstyle.pl
$ ./cstyle.pl src/exams/parallel-udp/*.c
src/exams/parallel-udp/client.c: 12: missing space between keyword and paren
src/exams/parallel-udp/client.c: 13: missing space between keyword and paren
src/exams/parallel-udp/client.c: 25: line > 80 characters
src/exams/parallel-udp/server.c: 14: missing space between keyword and paren
src/exams/parallel-udp/server.c: 15: missing space between keyword and paren
src/exams/parallel-udp/server.c: 25: missing space between keyword and paren
src/exams/parallel-udp/server.c: 45: line > 80 characters
src/exams/parallel-udp/server.c: 50: line > 80 characters
src/exams/parallel-udp/server.c: 56: line > 80 characters


Last changed: