Changed exit() calls to use EXIT_SUCCESS or EXIT_FAILURE.
Shortened a few print_*() function bodies.
Fixed idx incrementing in main() for format switch.