I'm creating a client-server application. I want to do some logging.
Server is in C. Now I'm print messages to the terminal. So I'll probably just copy that to sprintf and add timestamp. How can I do that timestamp? It should probably include date, hours, minutes, seconds.
On my PC, it just prints
Check out the whole range of time related functions here http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html
Please find the thread safe version of Pavan's answer below.
Please refer to this for more details.