- #1
aLostProgramm
- 2
- 0
HELP! How to process multiple files in C++
I have been bashing my head against my desk in my cubical trying to figure this out. I have approximately 500 files I would like to read in, one at a time, into a C++ program, do my processing, and send the results to a new file. I can do the processing just fine, but I can't increment the files. Below is what I have:
But instead of the highlighted 5's, I'd like it to be incremented, i.e. bTemp1.txt, bTemp2.txt, etc. Setting up the loop won't be a problem, I just need a quick, easy way to increment the files so I don't have to run the program once, change the program, run again... 500 times. I just want to send it through the loop.
Thanks in advance for a prompt response.
I have been bashing my head against my desk in my cubical trying to figure this out. I have approximately 500 files I would like to read in, one at a time, into a C++ program, do my processing, and send the results to a new file. I can do the processing just fine, but I can't increment the files. Below is what I have:
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
float temp1,temp2;
infile.open ("bTemp[COLOR="Red"]5[/COLOR].txt");
outfile.open ("finalBtemp[COLOR="red"]5[/COLOR].txt");
while (!infile.eof())
{
infile >> temp1 >> temp2;
temp1 = (temp1/100)+100;
temp2 = (temp2/100)+100;
outfile << temp1 << ' ' << temp2<<endl;
}
infile.close();
outfile.close();
return 0;
}
Thanks in advance for a prompt response.