#include <iostream>
#include <cstring>

void foo(char* s)
{
    char* next = std::strchr(s, ' ');
    if(next != nullptr)
    {
	    foo(next + 1);
    	*next = 0;
    }
    std::cout << s << " ";
}

int main()
{
    char s[] = "You are amazing";
    foo(s);
    std::cout << std::endl;
    foo("");
    std::cout << std::endl;
}