Quote Originally Posted by jamadagni
But I do not understand what struct tm *localtime means. Does it mean that localtime returns a pointer? And localtime(const time_t *tp) means that I have to give it a value or pointer (using &) as input? Please explain.
Yes, the localtime() function returns a pointer to tm struct.

So the following C code should work:

Qt Code:
  1. time_t now;
  2. struct tm * local;
  3. int year;
  4.  
  5. time( &now );
  6. local = localtime( &now );
  7.  
  8. year = local->tm_year;
To copy to clipboard, switch view to plain text mode 

BTW here is a good reference for the standard C time functions: http://www.cplusplus.com/ref/ctime/