fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. void foo(char* s)
  5. {
  6. char* next = std::strchr(s, ' ');
  7. if(next != nullptr)
  8. {
  9. foo(next + 1);
  10. *next = 0;
  11. }
  12. std::cout << s << " ";
  13. }
  14.  
  15. int main()
  16. {
  17. char s[] = "You are amazing";
  18. foo(s);
  19. std::cout << std::endl;
  20. foo("");
  21. std::cout << std::endl;
  22. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
amazing are You