fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. int main()
  6. {
  7. std::cout << "Please enter a date MM/DD/YY:" << std::endl;
  8. std::string m, d, y;
  9. std::getline(std::cin, m, '/'); //get month
  10. std::getline(std::cin, d, '/'); //get day
  11. std::getline(std::cin, y); //get year
  12.  
  13. int month, day, year;
  14. std::istringstream(m) >> month;
  15. std::istringstream(d) >> day;
  16. std::istringstream(y) >> year;
  17.  
  18. std::cout << "Month: " << month << std::endl;
  19. std::cout << "Day: " << day << std::endl;
  20. std::cout << "Year: " << year << std::endl;
  21. }
Success #stdin #stdout 0s 2988KB
stdin
03/5/13
stdout
Please enter a date MM/DD/YY:
Month: 3
Day: 5
Year: 13