view defical-c/src/basic/inefficient.cpp @ 1:758381a85d76 default tip

Incorrect printf format.
author Edho Prima Arief <me@myconan.net>
date Mon, 28 Jun 2010 14:52:19 +0700
parents ebed2bd0d300
children
line wrap: on
line source

#include <sstream>
#include "inefficient.h"

string uint32_t_to_str(uint32_t myint)
{
	stringstream tempstr;
	tempstr<<myint;
	return tempstr.str();
}

double stdev(uint32_t * numbers)
{
	//TODO
	return 0;
}

gettime::gettime()
{
	uint32_t year,month,day,hour,min,sec;
#ifdef _MSC_VER
	SYSTEMTIME st;
	GetLocalTime(&st);
	char temp[5];
	sprintf_s(temp,5,"%04d",st.wYear);
	year=atoi(temp);
	sprintf_s(temp,3,"%02d",st.wMonth);
	month=atoi(temp);
	sprintf_s(temp,3,"%02d",st.wDay);
	day=atoi(temp);
	sprintf_s(temp,3,"%02d",st.wHour);
	hour=atoi(temp);
	sprintf_s(temp,3,"%02d",st.wMinute);
	min=atoi(temp);
	sprintf_s(temp,3,"%02d",st.wSecond);
	sec=atoi(temp);
	sprintf_s(time_v,20,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec);
	sprintf_s(time_s,16,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec);
#else
	struct tm *mytm;
	time_t mytime;
	time(&mytime);
	mytm=gmtime(&mytime);
	year=mytm->tm_year+1900;
	month=mytm->tm_mon+1;
	day=mytm->tm_mday;
	hour=mytm->tm_hour;
	min=mytm->tm_min;
	sec=mytm->tm_sec;
	sprintf(time_v,"%04d-%02d-%02d %02d:%02d:%02d",year,month,day,hour,min,sec);
	sprintf(time_s,"%04d%02d%02d_%02d%02d%02d",year,month,day,hour,min,sec);
#endif
}