JoBlack Posted June 4, 2006 Report Share Posted June 4, 2006 Olá a todos Alguém me pode diser s.f.f. pq é que a seguinte função me dá erros? #include <dos.h> #include <stdio.h> void main () { struct date cl; getdate(&cl); printf("Ano: %d" ,cl.da_year; getch(); } Os erros são: 1. 'cl' uses undefined struct 'date' 2. 'getdate' : undeclared identifier 3. left of '.da_year' must have class/struct/union type Obrigado Link to comment Share on other sites More sharing options...
Elektron Posted June 4, 2006 Report Share Posted June 4, 2006 Tens de fazer: #include<ctime> Link to comment Share on other sites More sharing options...
TheDark Posted June 4, 2006 Report Share Posted June 4, 2006 Tens de fazer: #include<ctime> Isso é em C++. Se estás em C, é #include <time.h>. Estive à procura da struct date e não encontrei. Não será antes a struct tm que tens que utilizar? E a função getdate() não faz exactamente o que pretendes; recebe uma string com uma data formatada e transforma-a numa struct tm. Penso que queres usar a função time() para obter a hora actual (ou melhor, o número de segundos que passaram desde 01/01/1970) e depois a função ctime() para obteres o ano como uma string. Vê aqui: getdate() e <time.h> Desaparecido. Link to comment Share on other sites More sharing options...
Rui Carlos Posted June 5, 2006 Report Share Posted June 5, 2006 em unix podes usar a função 'localtime'. se for em windows não sei se dá... Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
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