The GNU indent tool works very well for the small C programs I have used it on. There is a windows version, too. It makes the indenting style moot, in my opinion. Just code in whatever style suits best. I prefer indent --line-length 90 -nut -brf -linux -i4
Code:
#include <stdio.h>
/* Print command line arguments and exit. */
int main (int c, char **v){
while (c--){
printf ("Argument %i is \"%s\"\n",c,v[c]);
}
return 0;
}
I misused flex to write a preprocessor to add missing or fix extra brackets and punctuation. I have no idea how to use flex and bison correctly, but that might be a benefit because my preprocessor does not understand C tokens (It just looks at indenting levels) so it works with other languages and scripts. To test the thing, I usually abuse it and code in a style like this, which is converted to the above style and compiled on the fly. With the tcc compiler, it also serves as sort of a scripting language that compiles C code and runs it in RAM. Though not as fast as code optimized with gcc, it is a lot faster than bash scripting :P:
Code:
#!/usr/local/bin/anch -run
/* This will run as a bash script if TCC and Anchor is installed */
#include <stdio.h>
/* Print command line arguments and exit. */
int main int c, char **v
while c--
printf "Argument %i is \"%s\"\n",c,v[c]
return 0