#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#const int LONG_CADENA=128;
int main(void)
{
time_t t1;
struct tm *t2;
char cadena[LONG_CADENA];
/* 1) get current date ('time_t') */
if ((t1 = time(NULL)) == (time_t) -1)
return EXIT_FAILURE;
/* 2)get current date ('struct tm *') */
t2 = localtime(&t1);
/* print date manually through printf */
printf("%d/", t2->tm_year + 1900);
printf("%02d/", t2->tm_mon + 1);
printf("%02d\n", t2->tm_mday);
/* prints date through strftime */
strftime(cadena, LONG_CADENA, "%Y/%m/%d", t2);
printf("%s\n", cadena);
return EXIT_SUCCESS;
}
Hello, when I compile the above code, give me an error, in line "struct tm *t2, type isn't correct:missing keyword typedef" but it's a correct code, because "struct tm " is defined on "time.h", any help?? :?