Oh merciful heavens please help me

I am trying to create a basic c++ code which reads data from an input file of suture data.
There are several rows of of four numbers in the file that are to be read: Batch number, and the corresponding pressure, temperature and dwell time for that batch number. Here is a small excerpt:
30026 160.4 71.2 2.49
30072 148.2 61.6 2.24
30106 151.8 63.7 2.38
30121 158.9 68.7 2.44
30145 170.1 69.8 2.21
30188 169.1 61.4 2.03
Eventually I have to determine for each batch whether the temperature pressure and time are within an appropriate range, and I must keep a running total of how many data are outside the appropriate range.
However I have just made code to test to see if I can read from the file and it is not working at all:

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

using namespace std;

int main() {
ifstream infile;
ofstream outfile;
string infilename;
string outfilename;

cout<< "Please input a file name" <<endl;
cin>> infilename;
infile.open(infilename.c_str());
if (infile.fail()){
cout<< "It failed" << endl;//test
}
cout << "Please enter an outfile name" <<endl;
cin >> outfilename;
outfile.open(outfilename.c_str());

int temp, press, time, batch;
int wtemp = 0, wpress = 0, wtime = 0;
while (infile >> batch>> temp >> press >> time) {
if (temp<150 || temp > 170) {
wtemp++;
}
if (press<60|| press>70) {
wpress++;
}
if (time<2.0 || time > 2.5) {
wtime ++;

}

}
infile.close();

cout << wtemp << wtime << wpress << endl;
return 0;




}

int temp, press, time, batch;
int is the wrong data type.

Why are you using C++ for this? Why not use something easier like Python?
Topic archived. No new replies allowed.