Hit a bump again. Heres the part of my program thats not going according to plan. with my inputted file i want it to output it exactly the same, then output another copy but in all caps. As of now, it outputs a regular line, then a cap line then regular line and so on . Any help is appreciated
cout << x << endl;
outFile << x << endl;
for (int i = 0; i < x.length(); i++)
cout << (char)(toupper(x.at(i)));
outFile << (char)(toupper(x.at(i)));
So do you want
Lines 5 and 6 output the line as read (without converting to upper case). These lines of code are executed immediately after reading every line. Then the code goes on to print the uppercase versions.
I'll leave you to guess what needs to be removed from your code.
i want it to output the line as read. I want it to output the entire file as read...and then the entire file as capitals.
currently what i have is:
instead, it should be:
Currently, you have a single loop that reads each line, writes it verbatim, then writes it in uppercase.
Originally Posted by brillpsycho
You need to change the order of events. For example;
1) A loop that reads the file, and outputs its contents verbatim. Close the file, reopen it for reading, then another loop to read it in and output the contents after converting to upper case.
2) A loop that reads the file, outputs the contents verbatim, and stores those contents (say, in an array). Then a second loop to loop over elements of that array, converting values to uppercase, and outputting them.
And, no, I am not going to provide code. If you aren't willing to put the effort in to converting a simple description (and I've given you two such descriptions) into code you have no business programming. Begging other people to do your work is not an effective development technique in the long run. Starting with your description, you should have been able to produce working code within minutes, even as a beginner. Starting with my description, the time you need should be even less, since I've given additional hints about how to implement it.
OMG Thank you! Im not asking for anyone to do my work for me, i just didn't even think about closing and reopening.
But maybe I do have no business programming. I've only been doing it for 5 weeks. I've read and re-read the book I have also. And been putting in hours upon hours trying to learn. Thanks again.
If you're willing to put in the effort, that's fine. My response may have been terse because some of your earlier posts seemed to keep coming back for more help with no visible sign of having tried to do something with the advice previously given. A few too many people do that here, and unfortunately assume it is their right to expect their work to be done for them. If that's not you, I apologise. If you show signs of effort (eg I did this, it did that, I don't understand why) you'll get more help than if you don't (asking for help, showing no signs of effort, then asking for help again on the same thing). Bear in mind that people in forums only see what you post, we can't read your minds.