Hello, I have this code that supposedly imitate a DTR for a homework. I've made the preliminary code, but I'm kinda surprised at the output since it's not what I had expected. Here's the code:
int login()
{
int id;
char* name, log_time;
time_t lt;
lt = time(NULL);
printf("\nPlease enter your ID: ");
scanf("%d", &id);
if ( (id < NUMOFEMPLOYEES) && (id >= 0) )
{
name = names[id];
printf("\n%d) %s ",login_counter, name);
printf("%s", (char* )asctime(localtime(<)));
login_times[login_counter] = (char* )asctime(localtime(<));
login_records[login_counter] = id;
login_counter++;
system("PAUSE");
} else
{
printf("INVALID ID.\n");
system("PAUSE");
}
return 0;
}
and when I iterate through login_times, all of them have the same time value. no other part of the code operates on the array but this snippet. What could be wrong? Is the string stored in the array changing too?
Thanks for the help, everyone.^^