In this post I'll tell how to store your cpu date and time in a text file . For this purpose we will be using "time.h" header file ... CPU time and date is nothing but the date you see when you log into into your OS....
This is helpful to keep log of activities on your C++ applications...
Program:
#include "iostream"
#include "iomanip.h"
#include "fstream.h"
using namespace std;
int main()
{
system("color ce");
cout<<setw(54)<<"*****-------------------*****\n";
cout<<setw(54)<<"*****C.P.U DATE AND TIME*****\n";
cout<<setw(54)<<"*****-------------------*****\n";
cout<<"\n\n\n\t\t\t";
ofstream fout;
fout.open("cputime.txt");
time_t t1;
time(&t1);
cout<<ctime(&t1);
fout<<ctime(&t1);
cout<<"\n\n\n\t\t\t\t\t";
fout.close();
return 0;
}
Output:
This is helpful to keep log of activities on your C++ applications...
Program:
#include "iostream"
#include "iomanip.h"
#include "fstream.h"
using namespace std;
int main()
{
system("color ce");
cout<<setw(54)<<"*****-------------------*****\n";
cout<<setw(54)<<"*****C.P.U DATE AND TIME*****\n";
cout<<setw(54)<<"*****-------------------*****\n";
cout<<"\n\n\n\t\t\t";
ofstream fout;
fout.open("cputime.txt");
time_t t1;
time(&t1);
cout<<ctime(&t1);
fout<<ctime(&t1);
cout<<"\n\n\n\t\t\t\t\t";
fout.close();
return 0;
}
Output:
Thanks....for the post it is really helpful...
ReplyDelete:-D