Keeping code correctly indented can be tedious.  And when the project is
large, maintaining a consistent style everywhere by hand can become
almost impossible.  `gnu-indent' solves this problem by doing the job
itself.  Enable `gnu-indent-mode' and continue with the your editing;
your file will be reindented by GNU Indent just before saving it,
maintaining the position of point.  Customize or set
`gnu-indent-options' as file local variable to change indentation style
according to your taste.

GNU Indent supports C, C++ is also partially supported.