How to use the asctime( ) function in C library <time.h> multiple times in a program?
I am working on a project about the Parking Management system. In the project, I need to find the number of hours spent in order to calculate the amount to be charged for parking. Although I can ask the user to enter time and then find the difference, I want my program to be able to do that by itself. For that i am using the asctime( ) function in the <time.h> library. But my program keeps returning the same value of time after subsequent calls. I have even tried storing the return value from asctime( ) in a file but it still isn't working To be a bit more precise, here is what I was doing int a ; time_t t = time(NULL); struct tm *tm = localtime(&t); char *s= asctime(tm), *z ; printf("%s",s) ; scanf("%d",&a) ; z= asctime(tm) ; printf("%s",z) ; I added a scanf( ) statement to pause the program with the intention that as time was still running, the next call to asctime( ) would give a different value of time. I even stored it in a different pointer array but it STILL ended up printing the exact same time. Is there a way through which subsequent calls to asctime( ) returns different values for the time and not the same value again and again. Your help is highly appreciated. Thanks!!