Baran Topal

Baran Topal


March 2024
M T W T F S S
« Feb    
 123
45678910
11121314151617
18192021222324
25262728293031

Categories


size of time_t out of the blue

baranbaran

The output of the following program heavily depends on your architecture:

# include <stdio.h>
# include <iostream>
# include <time.h>
using namespace std;
size_t getPtrSize( char *ptr )
{
 return sizeof( ptr );
}

int main()
{
 time_t lt;

 lt = time(NULL);
 cout << "Date: " << ctime(&lt) << endl;

 cout << "\nThe length of " << ctime(&lt) << " is: "
 << sizeof ctime(&lt)
 << "\nThe size of the pointer is "
 << getPtrSize( ctime(&lt) ) << endl;

 cout << " or " << sizeof(time_t);
 return 0;
}

The output is as follows:


The length of Tue Dec 27 01:43:42 2016
is: 8
The size of the pointer is 8
or 8