L
Larry
Hi,
I am experiencing strange behavior with this code: It basicaly says 1
hours and 2 seconds (01:00:02) elapsed between the first block and the
second:
#include <windows.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
int main()
{
time_t start = time(NULL);
{
struct tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
localtime_s(&timeinfo, &start);
char szTime[30] = {0};
strftime(szTime, 30, "%X", &timeinfo);
std::cout << "Start: " << szTime << std::endl;
}
Sleep(2000);
time_t end = time(NULL);
{
struct tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
time_t dif = (time_t)difftime(end, start);
localtime_s(&timeinfo, &dif);
char szTime[30] = {0};
strftime(szTime, 30, "%X", &timeinfo);
std::cout << "End, time elapsed is: " << szTime << std::endl;
}
system("pause");
return EXIT_SUCCESS;
}
what am I missing?
thanks
I am experiencing strange behavior with this code: It basicaly says 1
hours and 2 seconds (01:00:02) elapsed between the first block and the
second:
#include <windows.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
int main()
{
time_t start = time(NULL);
{
struct tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
localtime_s(&timeinfo, &start);
char szTime[30] = {0};
strftime(szTime, 30, "%X", &timeinfo);
std::cout << "Start: " << szTime << std::endl;
}
Sleep(2000);
time_t end = time(NULL);
{
struct tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
time_t dif = (time_t)difftime(end, start);
localtime_s(&timeinfo, &dif);
char szTime[30] = {0};
strftime(szTime, 30, "%X", &timeinfo);
std::cout << "End, time elapsed is: " << szTime << std::endl;
}
system("pause");
return EXIT_SUCCESS;
}
what am I missing?
thanks