pakito87 Posted April 11, 2009 at 05:12 PM Report #256302 Posted April 11, 2009 at 05:12 PM Boas pessoal, no projecto que estou a desenvolver eu precisava de fazer inserir datas, mais propriamente anos, o que se passa e que não vou definir uma data máxima como por exemplo 2009, porque se não em 2010 tinha-se que voltar a alterar o código. Sabem alguma função que atribuía só o ano em que nos encontramos. ando a procura na biblioteca time.h mas ainda não encontrei. Abraços 😞
Rui Carlos Posted April 11, 2009 at 05:24 PM Report #256307 Posted April 11, 2009 at 05:24 PM Vê este exemplo: #include <stdio.h> #include <time.h> int main () { time_t t; struct tm* st; time(&t); st=localtime(&t); printf("%d\n",st->tm_year); return 0; } Rui Carlos Gonçalves
pakito87 Posted April 11, 2009 at 05:38 PM Author Report #256310 Posted April 11, 2009 at 05:38 PM a função n tem erros mas n ta correcta esta-m a dar o valor 109 :/
Solution Rui Carlos Posted April 11, 2009 at 05:48 PM Solution Report #256314 Posted April 11, 2009 at 05:48 PM Soma 1900 ao 109 (ou lê a documentação do tipo struct tm). Rui Carlos Gonçalves
pakito87 Posted April 11, 2009 at 05:52 PM Author Report #256316 Posted April 11, 2009 at 05:52 PM exactamente tive tava agora mesmo a ver isso, já funciona a 100% obrigadão pela ajuda
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now