How to get the time?

closed account (yCf9216C)
I need to get the current time. I looked up time using the search feature, but I can't find any C++ time functions or headers. I only found time.h, and that's for C.
Here you go :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <time.h>
#include <windows.h>
#include <ctime>

using namespace std;

int main()
{
        while(1)
    {
        time_t current = time(0);
        cout << ctime(&current);
        system("cls");
    }
}

//EXPLANING THE CODE

//time_t is a type used to hold time values.
//Usually represents the number of seconds since 1970.

//time(0) returns the current time as a time_t object.
//ctime() converts the parameter to a human readable
//string representing the time stored.
closed account (yCf9216C)
Thank you, but why am I getting an LNK 2019 error in VS 2010 express?
Im not sure, i dont use VS i use code blocks, someone else will have to help you with that.
Topic archived. No new replies allowed.