fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include<iomanip>
  4. #include<stdlib.h>
  5. #include<string.h>
  6. #include <string>
  7. #include<stdio.h>
  8. #include<time.h>
  9. #include<ctype.h>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. time_t mytime;
  15. mytime = time(NULL);
  16. std::string ques, answer;
  17.  
  18. cout << setw(75) << "Welcome To Talk Back\n\n";
  19.  
  20. do
  21. {
  22. cout << "So, What do you have in mind ? ";
  23. std::getline (std::cin, ques);
  24. std::cin.clear();
  25.  
  26. //Convert string to uppercase
  27. for (auto& character : ques)
  28. {
  29. character = toupper(character);
  30. }
  31.  
  32. if (ques.find("TIME") != std::string::npos)
  33. {
  34. cout<<"\n\nThe Time and Date as of now is : "<< ctime(&mytime);
  35. }
  36.  
  37. std::cout << ques << std::endl;
  38.  
  39. cout<<"Anything Else ? Y/N " << std::endl;
  40. std::getline (std::cin, answer);
  41. std::cin.clear();
  42. std::cout << "Reply: " << answer << std::endl;
  43. }
  44. while ("Y" == answer || "y" == answer);
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 3464KB
stdin
time
y
THe Time
n
stdout
                                                     Welcome To Talk Back

So, What do you have in mind ? 

The Time and Date as of now is  : Thu Sep  3 16:01:37 2015
TIME
Anything Else ? Y/N 
Reply: y
So, What do you have in mind ? 

The Time and Date as of now is  : Thu Sep  3 16:01:37 2015
THE TIME
Anything Else ? Y/N 
Reply: n