1

I want to write a C++ code for checking if the person is above 18 yrs old but not by asking the age but by the DOB of the person. Is there any way which can help me in getting the current Date from the system?

Atin Singhal
  • 13
  • 2
  • 4

1 Answers1

2
#include <iostream>
#include <ctime>

void printTime() {
    time_t t = time(0); 
    struct tm * timeStruct = localtime(&t);
    std::cout << (timeStruct->tm_year) << '-' << (timeStruct->tm_mon) << '-'<<  (timeStruct->tm_mday) << std::endl;
}