C/C++ useful functions