Hello.
I am just finishing a project and I have gotten passed all of the other bugs I've had without help from others but this is my last issue and it's driving me nuts!
I have a program that I'm taking in data from ifstream and outputting ofstream. It takes in a int for month and an int for rainfall.
I need a function called getInput to simply bring in 2 pieces of data at a time and then pass back to main. If I put this statement in main, the program works fine:
But if I use that in a function, the data is restarted from the beginning each time.Code:in_stream >> month >> rainfall;
Here is the function i'm using:
I also appoligize for all of the comments but I have been trying many different things.Code:void getInput (int &rmonth, int &rrainfall) { //::input(ifstream& inData) //ifstream in_stream("rainInput.txt", ios::cur, ios::in); //in_stream.open ("rainInput.txt", ifstream::in); fstream in_stream; in_stream.open("rainInput.txt"); in_stream >> rmonth >> rrainfall; //in_stream.close(); //in_stream.clear(); }
How can I have the function take in data from the last that was taken in?
It's probably very simple but I'm reaching my frustration limit with streams.
Thanks in advance.