To what initilizer or data type, can I set it with value from ctime()?

Hello, I am a beginner trying to familiarize with functions related to 'time'. I was looking to modify a time output below so that it will have only one line of output instead of hundreds of them thru loop.

1
2
3
4
5
6
7

	while(1)
{
	time_t current = time(0);	
    cout << ctime(&current) << endl;
}


what I figured was making another variable and set it to 'ctime(&current)' but none of int, double, char, and few more in my knowledge would work.

and also, once I get the data for time (hr:min:sec), is there a way I can extract each data of hr,min,and sec from it?
http://www.cplusplus.com/reference/ctime/
explains function ctime. That seem to return a C-string. There are other functions too.
Topic archived. No new replies allowed.