The trouble is you think you have time. Your success depends on how you utilize your time.

How to find date and time in C++ easiest way

To find date and time in c plus plus you have to use a header file known as windows.h
When you will include this you will be able to use a function known as getlocaltime() as well as a class Systemtime. Now you just have to create an object of SYSTEMTIME class and call getlocaltime function and pass the address of the object in this function and all the data will be stored about time and date in the object. Now you just have you use the date. Following is the example:

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
  SYSTEMTIME obj;

  Getlocaltime(&obj);
  cout<< obj.wDay <<endl ;
  cout<< obj.wMonth <<endl ;
  cout<< obj.wYear <<endl ;
  cout<< obj.wHour<<endl; //wMinute and wSecond can also b used  
}
 What Video Click HERE:

find date and time in C++ easiest way


Also, understand that what is library or header filers  Click HERE

No comments:

Post a Comment