In the code below i can'f figure out how to get the numbers from my inFile that will be reversed then put into my outFile. I left part of the code unfinished. not sure what I am supposed to put in between >> >>. pretty lost on this one. Im new at this so go easy. Thanks

#include <iostream>
#include <string>
#include <fstream>

using namespace std;
std::string word[5];

int main ()
    //Declaring Variables
ifstream inFile;
ifstream inFile1;
ofstream outFile;

int item[5]; // An array item of 5 components
int counter;
int num, num1, num2, num3, num4;"numbers.txt");"words.txt");"numberout.txt");

for (counter = 0; counter < 5; counter++)
inFile >> num >> num1 >> num2 >> num3 >> num4;

for (counter = 5; counter >= 0; counter--)
// unfinished code
outFile <<  << endl;

You need to rethink why you are using a loop.
Ideally, if you have to do things multiple times, it suggests a loop and/or an array.

Since you need to remember five numbers, instead of writing: int num, num1, num2, ... you can instead just use an array: int items[ 5 ]; I would have named it "numbers": int numbers[ 5 ]; (But I'll still use "items" below.)

Now below, you want to read 5 numbers (and remember them). You've got a nice loop there that counts from 0 to 4, and a nice array, so let's put them together:

for (counter = 0; counter < 5; counter++)
  cin >> items[ counter ];

You've already got a nice loop there that counts from 5 to 0. You'll have to fix that five to the proper number to start at. (Remember, arrays are index from 0 to N-1, where N is the number of elements in the array.) And I think you should know by now what goes inside the loop.

Hope this helps.

Thank you for the help. What you said worked perfectly. I just can't believe I didn't see it before. Thanks again for help.


Heh, don't feel bad. Nothing is obvious until you see it. You'll do fine.