Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void readoriginaldate (string &);
- void breakoriginaldate(string, string&, string&, string&);
- int main()
- {
- string originaldate, month, day, year;
- readoriginaldate(originaldate);
- breakoriginaldate(originaldate, month, day, year);
- return 0;
- }
- void readoriginaldate (string &origdate)
- {
- int s;
- cout<<"Please enter the date in MM/DD/YY format, seperated by slashes."<<endl;
- cout<<"For example, 6/11/08"<<endl;
- getline(cin, origdate);
- s=origdate.size();
- while (s>8||s<6){
- cout<<"The date you have entered is invalid."<<endl;
- cout<<"Please enter the date in MM/DD/YY format, seperated by slashes."<<endl;
- cout<<"For example, 6/11/08"<<endl;
- getline(cin, origdate);
- s=origdate.size();
- }
- cout<<origdate<<" is the original date"<<endl;
- return;
- }
- void breakoriginaldate (string origdate, string &month, string &day, string &year)
- {
- int slash;
- slash=origdate.find("/",0);
- month=origdate.substr(0,slash);
- cout<<month<<" is the month"<<endl;
- origdate.erase(0, slash);
- slash=origdate.find("/",0);
- day=origdate.substr(0,slash);
- cout<<day<<" is the day"<<endl;
- origdate.erase(0, slash);
- year=origdate;
- cout<<year<<" is the year"<<endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement