-5

This is to save a filename as the current date. One of the lines of codes are as follows. I can't understand what the local->tm_mday means

The code is:

time_t my_time = time(NULL);
struct tm *local = localtime(&my_time);
 
day = local->tm_mday;            
month = local->tm_mon + 1;       
year = local->tm_year + 1900; 
Nozakai
  • 11
  • 2

1 Answers1

4

If you don't know what a struct member means, look at the documentation for that struct.

In this case that's tm, from <time.h> (or <ctime> in C++)

Member objects

  • int tm_mday day of the month – [1, 31]

That's different to

  • int tm_wday days since Sunday – [0, 6]
  • int tm_yday days since January 1 – [0, 365]
Caleth
  • 52,200
  • 2
  • 44
  • 75