fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. void ReverseSentences(char *str)
  7. {
  8. for(char * s = strtok(str, ".!?"); s;
  9. s = strtok(NULL, ".!?"))
  10. {
  11. for(char * e = s + strlen(s) - 1, *b = s; b < e; ++b, --e)
  12. {
  13. char t = *b; *b = *e; *e = t;
  14. }
  15. cout << s << endl;
  16. }
  17. }
  18.  
  19. int main(int argc, const char * argv[])
  20. {
  21. char sent[] = "I said hello, Dolly. well, hello, Dolly. It's so nice to have you back where you belong.";
  22. ReverseSentences(sent);
  23.  
  24. }
  25.  
  26.  
Success #stdin #stdout 0s 4216KB
stdin
Standard input is empty
stdout
ylloD ,olleh dias I
ylloD ,olleh ,llew 
gnoleb uoy erehw kcab uoy evah ot ecin os s'tI