Darren Provine at Rowan University


Formatting Instructions for C/C++/Java

astyle, an automatic code formatter for C/C++/Java, has been installed on Elvis.

The options I like are:

    astyle -C --style=linux -s4 filename
where filename is something like "foobar.C". The program will make a copy of your program in "filename.orig", so if something bad happens you can copy this back to the original name.

Always check a file after formatting to ensure it looks okay. If a file has been mangled and you re-run the formatter, the original will be destroyed.

(A previous version of this page suggested "-c" as well, which the documentation claims is good, but which the program rejects. I'm looking into it.)


(US flag) This page's URI: http://elvis.rowan.edu/~kilroy/class/elvis/?format
Last modified: Friday, 11 April 2008, 1:51:29pm