Some useful routines for C programming