Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
struct tm * timeinfo;
 
  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
 cout<<"The Check in time is : " <<asctime (timeinfo);
 ofstream customerfile ("customers.txt", ios::out | ios::app );
 
string day;
string month;
string date;
cout<<"Please fill the check out time data :"<<endl;
 
cout<<"The Day of check out : \n";
cin>>day;
cout<<"The Month of check out : \n";
cin>>month;
cout<<"The Date of check out  : \n";
cin>>date;
string chkout = day + month + date + (asctime (timeinfo)+10);

if (customerfile.is_open())
{
customerfile<< asctime (timeinfo)<<","<< chkout<<"\n";}
customerfile.close();
				
				
				
				system ("pause");
				goto Main_Menu;
				break;
			}
Posted
Updated 10-May-12 19:29pm
v2
Comments
Sandeep Mewara 11-May-12 1:34am    
Taking time of 'future' and then calculating the check-in check-out time difference? Not clear.

If it's checkin & checkout time then all you need is to take two times and then find the difference.

Use the mktime function to create a future time.
Fill in the values in a tm structure and pass this to the mktime function.

To get the difference between 2 time values, use the difftime function.
 
Share this answer
 
As you're using C++ I'd run, not walk over to Boost[^] and grab the latest version of their library. The date/time library is pretty clean and functional but it'll clonk some time on your compilation (a couple of seconds per source file).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900