Hi C++ fans!
// GMT.cpp : Defines the entry point for the console application.
// Friday, January 18, 2013 3:55 PM
#include "stdafx.h"
// crt_gmtime.c
// compile with: /W3
// This program uses _gmtime64 to convert a long-
// integer representation of coordinated universal time
// to a structure named newtime, then uses asctime to
// convert this structure to an output string.
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
struct tm *newtime;
struct tm today;
__int64 ltime;
char buff[128];
errno_t err;
_time64( <ime );
// Obtain coordinated universal time:
newtime = _gmtime64( <ime ); // C4996
// Note: _gmtime64 is deprecated; consider using _gmtime64_s
asctime_s( buff, sizeof(buff), newtime );
int i;
for ( i = 0; i < sizeof(buff); i++ )
{ // Remove line Feed with Space
if( buff [ i ] == 10 ) buff [ i ] = 32;
}
cout << "Coordinated universal time is "
<< buff << "UTC"
<< endl;
// Use time structure to build a customized time string.
err = _localtime64_s( &today, <ime );
if (err)
{
cout << " _localtime64_s failed due to Bad arguments.";
exit(1);
}
strftime( buff, 128,
"Today is %A, day %d of %B in the year %Y.\n", &today );
cout << buff;
strftime( buff, sizeof(buff),"%#c %p %z", &today );
cout << buff << endl;
_getch(); // Wait!
return 0;
}
/* expected output
Coordinated universal time is Fri Jan 18 22:00:58 2013 UTC
Today is Friday, day 18 of January in the year 2013.
Friday, January 18, 2013 17:00:58 PM EST
*/
I have Windows XP SP3
Regards Herge
Hi Vortex:
Yes it is C++ but C is quicker to type.
I prefer an old Borland compiler.
Regards Herge
Hi herge,
and what is your question?
Gunther
Hi Gunther:
What's up?
Regards herge
I have discovered if you go Microsoft with AOL 9
you get a lot of internet script errors. But if I use IE it works
well even with the reduced band width because
Aol has the connection.
Regards Herge
Hi Everbody:
To get rid of specific warning in 2008 vc++ or 2005 vc++
1>c:\documents and settings\user\my documents\visual studio 2008\projects\gmt\gmt\gmt.cpp(25) : warning C4996: '_gmtime64': This function or variable may be unsafe. Consider using _gmtime64_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\time.h(209) : see declaration of '_gmtime64'
Project Properties
Configuration Properties
C/C++
Advanced
Disable Specific Warnings
4996
OK
You will find the
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_DEPRECATE 1
#pragma warning( disable : 4996 )
Will not work!
Regards herge
Deleted..
Hutch - I was replying to another post and it posted here !
This is with reference to the logging in - and posting problem I mentioned earlier :0