Write the definition of a function named copy that reads all the strings remaining to be read in standard input and displays them, one on a line with no other spacing, onto standard output .
I know I'm supposed to write a recursive function, but not sure how to do that with cin and cout. I got all the other ones right but this one is stumping me.
I guess it reads in a list of strings and then is supposed to output them all in one line with now spaces. That is just how it's stated, hence my confusion.
This goes into a infinite loop when I submit it. It a stupid my programming lab assignment and it has to be done their way. I'm assuming I have a line that reads something like this "Here comes the sun". It wants me to read in each word to string x and then output the whole string.
Gotcha. Yeah I forgot with strings the only real way to make cin.fail return true is if you press Ctrl + z in the console and press enter. That will break the loop.
Mostly.. apparently it is supposed to be void and can't accept any parameter. This is the dumbest assignment ever. How would you just recursively call the cin function?
Well you basically are already recursively calling the cin function because every time the function is called, you have to cin a value. Are you allowed to use global variables?
That code is what is within My Programming Lab. Other than the brief sentence in the first post the only thing is says I cannot do is use a loop (obviously... it has to be recursive).
Keep in mind that if the input is coming from the user (the keyboard), then the condition on line 7 will never be satisfied, and it'll just keep on asking for more input.
So I would either get the input from a file instead, or just enter a EOF character (Ctrl+Z on a blank line in Windows; not sure about other OSs) when you're done entering your input.