Rewrite print function in C