LINUX.ORG.RU

Ответ на: комментарий от anonymous

Соси! А это по твоему на чем!

anonymous
()

struct timeval
{
    __time_t      tv_sec;   /* Seconds */
    __suseconds_t tv_usec;  /* Microseconds */
};

Есть такая структура. Ее используют следующим образом:

#include <sys/time.h>
#include <stdio.h>

int main()
{
    struct timeval tv;
    if (gettimeofday(&tv) == -1)
        return (1);
    printf("%d seconds, %d microseconds since 1 jan 1970\n",
        (unsigned long)tv.tv_sec, (unsigned long)tv.tv_usec);
    return (0);
}

ay49Mihas
()

#include <time.h>
#include <string.h>

int
main(int argc, char **argv)
{
	time_t now = time(NULL),
	       dayStart;
	struct tm nowStruct = gmtime(&now),
		  dayStartStruct;
	memcpy(&dayStart, &now, sizeof(struct tm));
	dayStart.tm_hour = 0;
	dayStart.tm_min  = 0;
	dayStart.tm_sec  = 1;
	dayStart = mktime(&dayStartStruct);
	return(now - dayStart);
}

anonymous
()
Ответ на: комментарий от anonymous

очень извеняюсь, ошибочка вышла..

#include <time.h>
#include <string.h>

int
main(int argc, char **argv)
{
	time_t now = time(NULL),
	       dayStart;
	struct tm nowStruct = gmtime(&now),
		  dayStartStruct;
	memcpy(&dayStartStruct, &nowStruct, sizeof(struct tm));
	dayStartStruct.tm_hour = 0;
	dayStartStruct.tm_min  = 0;
	dayStartStruct.tm_sec  = 1;
	dayStart = mktime(&dayStartStruct);
	return(now - dayStart);
}

anonymous
()
Ответ на: комментарий от anonymous

>Мне кажется на Perl проще и быстрее Проще и быстрее чем вызов gettimeofday() ??

mky ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.