Looping Question-Don't know where to put this

Sorry I put this twice. Don't know if it's general or beginner...

So my assignment is to make this program run as many times as the user wants, then create a file with multiple outputs.

With my research I was able to deduce that I need to use the do loop. Even then from my online research I'm not really getting anything clear. I tried adding do while but it only seemed to skip questions and not even give me an output. I know where is x>=1 stuff but I can't see how I could implement that into my coding. There must be a simpler way of doing that I just haven't seen.

Long story short, user enters input, gives output, console asks if user wants to enter another set of input, gives output, send all outputs to one file.





EDIT: I was basing my opinion on do loop off this youtube video
http://www.youtube.com/watch?v=BVVXLvMs_-w
It seemed closest to what I'm trying to accomplish but I'm not getting the same results.
Last edited on
I was able to figure it out up to




Can I make multiple outputs appear at once or does the previous output need to be cleared? Also how do I send multiple outputs to a file?
Last edited on
Could anyone assist me? :(
So, you just need help with the file output? It seems like you got the rest.

http://www.cplusplus.com/doc/tutorial/files/
Here is the tutorial on this website about file input/output. Give it a shot and let us know if you hit any problems.
What what about my other question? Could I make multiple outputs appear or will one continuously replace the other?
No, you can make multiple outputs. That tutorial tells you how to output. It pretty much the same as cout, but instead of using cout, you'll use the stream.

For example:
1
2
3
ofstream outfile("test_file.txt");
outfile << "This goes to the file." << endl;
outfile << variable_out << " : " << variable_out2 << endl;
So I have this thus far:

Now the output only comes up in the text file. Is there any way to make it come up both in the program AND the text file?
BTW I know my loop is wrong, just ignore that.
Last edited on
I realize what's happening. It's skipping the output and skipping directly to the continue cout. How would I go about display it all at once?
Where'd your code go, man? Haha! I can't help much if the code disappears. :P
Topic archived. No new replies allowed.