Baran Topal

Baran Topal


October 2024
M T W T F S S
« Feb    
 123456
78910111213
14151617181920
21222324252627
28293031  

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