Hi, Iam trying to compare to random dates/times but am unable to create 2 independent times as it wont let me decalre 2 individual time_t variables, it will just overight the first variable with the second one.
Is it not possible to create 2 indivudual random dates/time based on systemtime modify one and the other is not changed?
If it is possible could someone tell me how I am to initialise it correctly, as at the momoent I am using:
ThanksCode:#include<iostream> #include<string> #include<time.h> using namespace std; int main() { char t1[123]; char t2[123]; time_t time1 = time(NULL); time_t time2 = time(NULL) + (a constant); tm *ltime1 = gmtime(&time1); tm *ltime = gmtime(&time2); strtime(t1,123,"%a,%b,%Y", ltime1); strtime(t1,123,"%a,%b,%Y", ltime2); cout<<t1<<endl; cout<<t2<<endl; return 0; }



LinkBack URL
About LinkBacks


