Ah! Why didn't I ever think of making a copy of the string itself to prevent overwriting! Now problem solved! Thanks! However, I would just like to clarify some things. I don't know why you guys get errors but I don't? not even a warning.I'm using code blocks as my compiler and also have dev c++ which I don't usually use. And for that ctime_r, I can't use it. compiler said "unidentified reference to 'ctime_r' " what I did is this :
And also with the "int main" and "return 0". We were also taught to use that on our program.However, I found out that nothing happens to the program if I don't put it. I'm just wondering what is that for? It's just that I might have already be missing some concepts about that.
typedef char string ;
printf("Press enter to get the date today\n");
start_time = time(NULL);
printf("%s - %d\n",start,start_time);
printf("Enter again to get the latest date\n");
end_time = time(NULL);
printf("%s - %d\n",end,end_time);
printf("And the time a while ago is %s - %d\n",start,start_time);
And also for the "end_time = time(end_time)". That's my bad. I forgot to change it back to the original code. Like I said a while ago, I was already been messing with that code for a long time. And for gemere, changing the argument of the time to NULL didn't do the trick.