help on time.h

i want to get the date,month,year of 5days from now(eg:if today is 29 october 2013 i want 3 november 2013) .how to do it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <ctime>
#include <iostream>

int main()
{
    time_t rawtime;
    struct tm* now;
    struct tm* later;

    time(&rawtime);
    now = localtime(&rawtime);

    std::cout << "Current time & date: " 
              << asctime(now);

    rawtime += (60 * 60 * 24 * 5);
    later = localtime(&rawtime);

    std::cout << "5 days from now: " 
              << asctime(later);
}
Current time & date: Fri Oct 18: 10:03:35 2013
5 days from now: Wed Oct 23 10:03:35 2013

Last edited on
thanks
could you plz explain the code and how it works. Thanks in advance
Topic archived. No new replies allowed.