Mudanças entre as edições de "Aula 16/06/15"
Ir para navegação
Ir para pesquisar
Linha 1: | Linha 1: | ||
==Aula 16/06/15== | ==Aula 16/06/15== | ||
− | ===''Trabalhando tempo em C''=== | + | ==='''Trabalhando tempo em C'''=== |
+ | |||
+ | <syntaxhighlight lang=c> | ||
+ | #include <stdio.h> | ||
+ | #include <time.h> | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | |||
+ | time_t rawtime; // tipo de dados time_t | ||
+ | struct tm *tminfo; | ||
+ | |||
+ | time ( &rawtime ); | ||
+ | tminfo = localtime ( &rawtime ); | ||
+ | printf ( "hora: %d minuto: %d segundo: %d \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec); | ||
+ | printf ( "%d:%d:%d \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec); | ||
+ | printf ( "%dh%dmin%ds \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec); | ||
+ | } | ||
+ | </syntaxhighlight> |
Edição das 15h52min de 16 de junho de 2015
Aula 16/06/15
Trabalhando tempo em C
#include <stdio.h>
#include <time.h>
main()
{
time_t rawtime; // tipo de dados time_t
struct tm *tminfo;
time ( &rawtime );
tminfo = localtime ( &rawtime );
printf ( "hora: %d minuto: %d segundo: %d \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec);
printf ( "%d:%d:%d \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec);
printf ( "%dh%dmin%ds \n", tminfo->tm_hour, tminfo->tm_min, tminfo->tm_sec);
}