Useful functions for console I/O in C