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 :
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
typedef char string [128];
time_t start_time,end_time;
char* start,*end;
string store[5];
printf("Press enter to get the date today\n");
system("PAUSE");
start_time = time(NULL);
ctime_r(&start_time,store[1]);
printf("%s - %d\n",start,start_time);
printf("Enter again to get the latest date\n");
system("PAUSE");
end_time = time(NULL);
ctime_r(&end_time,store[2]);
printf("%s - %d\n",end,end_time);
printf("And the time a while ago is %s - %d\n",start,start_time);
system("PAUSE");
return 0;
}
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.
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.