-
[C++] Time Difference
I made this program cause i got bored. All it does is counts to the number you put in. Very simple. Not my first program but i decided alot of people are getting alot of compliments for what they show and i feel like im just sucking information out of people without showing them the end project.
Code:
#include <cstdlib>
#include <iostream>
#include <time.h>
using namespace std;
int x = 0;
char * buffer;
long size;
time_t start, end;
double dif;
int main()
{
int z;
cout << "Please enter the number you wish the program to count to:\n";
cin >> z;
time (&start);
while ( x < z)
{
x++;
cout << x << endl;
{
}
}
time (&end);
dif = difftime (end,start);
cout << "it took " << dif << "seconds" << endl;
system("pause");
}
Just counts to the number your requested and tells you how long it took in seconds. I will update in Minutes eventually if i get bored again.