I am having problems getting my procedure to read characters recursively to terminate. Can somebody help me here, I am not suppose to use arrays or lists. I have the following procedure:

void recursive()
{
	char c;
	cin>>c;
	cout<<c;
	recursive();
	return;
}

I also need to print the characters backwards.

Recommended Answers

All 7 Replies

Well... when do you want it to terminate?

And why are you asking a question like this in the wrong thread.

I need it to terminate when the last character is found. It reads all the characters but simply does not find the end.

And what thread should I use. I thought compilers fit into computer science

This is not a C++ question? This certainly isn't a compiler question...

So the question is: How to detect when last character found? You surely know how to do that? Well then, finding the recursive function that outputs them in reverse order is a simple matter of mentally stimulating exploration! Good luck!

I know how to do the inverse order. What I am having problems is with the base case for the recursion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.