I think that the purpose of the assignment is to learn to write recursive functions. You should write a recursive function that displays digits of a number in the direct order.
What error did you get? Note that I made a mistake in my previous post: in last line it should be c instead of x. Probably you have an outdated compiler. If so next code will help you.
1 2 3 4 5
std::string x;
std::cin >> x;
for(char c: x)for(int i = 0; i < x.size(); ++i)
std::cout << x[i] << std::endl;