AMC dimPCI 68VZ328 Manual do Utilizador Página 51

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 115
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 50
www.amctechcorp.com 51
}
This program will read the date from the kernel clock and print it out to the standard output
stream.
// date.c
//
// This will read the date from the realtime clock and
// display it on screen.
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
void main() {
struct timeval time_val;
// read the date from the realtime clock
gettimeofday(&time_val, NULL);
// display the value from the clock
printf(“%s”, ctime((time_t *) &time_val.tv_sec));
}
The following program writes a given date to the kernel clock and then commits it to the hard-
ware real-time clock.
// rtc.c
//
// This program will first set the date on the real time clock
to
// Fri May 25 10:21:00 2001 and then read it back and display
it.
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
void main ()
{
struct timeval time_val;
struct tm tm_val;
// load the time we are setting into the time structure
tm_val.tm_sec = 0;
tm_val.tm_min = 21;
tm_val.tm_hour = 10;
tm_val.tm_mday = 25;
tm_val.tm_mon = 4;
tm_val.tm_year = 2001 - 1900;
tm_val.tm_wday = 5;
Vista de página 50
1 2 ... 46 47 48 49 50 51 52 53 54 55 56 ... 114 115

Comentários a estes Manuais

Sem comentários