oh my goodness, I thought my variable "line" was holding the text input from the input file and that once line was put into my outfile it would end at the null.
so it seems my entire logic is flawed here. what do you think? should I create an array in place of my line variable to hold the text input from the text file?
I got confused because when I output "line" to the screen, I got the correct result. It was only when I tried t write it to the output file that it blew up.
edited to add:
or --- are you saying that it's the while loop in the output that is causing the problem? maybe I don't need the while loop there at all?
The obvious thing to do, if you're just copying the content verbatim with line-oriented operations would be to open infile for reading, outfile for writing and:
1 2
while ( getline(infile, line) )
outfile << line << '\n' ;
I tried removing the while loop real quick. Now by output file doesn't blow up. You guys are so smart! Thank you.
But only get one line of my text into the output file. I should have all 4-5 lines in it. Basically it should have everything the input file had in it.
For example, if my input is
"Hello world.
Today is Saturday.
I spend all my free time learning C++."
Then my output text file should contain all 3 lines.
Does it stop writing because of the carriage return?
Do I need some other type to hold the entire string?
Is it an array I need?
I really love learning this, but I honestly have to say that if it wasn't for all of you wonderful people helping and encouraging me as I learn, I may have thrown in the towel several times already. So, thank you very much.