Why does the following work:
<code>
#include <stdio.h>
#include <time.h>
int main()
{
time_t now;
time(&now);
printf("It's now %s\n",ctime(&now));
return 0;
}
</code>
And not the following:
<code>
#include <stdio.h>
#include <time.h>
int main()
{
time_t *now;
time(now);
printf("It's now %s\n",ctime(now));
return 0;
}
</code>
I assume that it is because pointers have to be pointed to a memory location when initialized but, I am not sure of the syntax. I tried:
time_t *now = new time_t;
as suggested in the tutorials but, that just gave me errors.