Baran Topal

Baran Topal


September 2022
M T W T F S S
« Feb    
 1234
567891011
12131415161718
19202122232425
2627282930  

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