I have a code that is reading lines from a .txt file. In this case ABC.txt.
(This is a CLR Console Application)
The lines in the file is:
12/01/1999,1652,21.00
12/01/1999,1653,21.00
Now I have a question in mind here. The code is working great but I wonder for the line:
Instead of writing this line here. Is it possible to #include a Headerfile from where this line is red instead. To refer to for ex a statement in the included file ?Code:if (Time > 1652)
If it is possible, will this be a slower process then writing it in the code directly.
Code:#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main ()
{
std::string Date;
int Time = 0;
char Comma;
double Grad = 0;
ofstream Main;
Main.open ("MainFile.txt");
ifstream myfile ("ABC.txt");
while (getline(myfile, Date, ','))
{
myfile >> Time;
myfile >> Comma;
myfile >> Grad;
myfile.get(); // read in trailing newline character
if (Time > 1652)
{
Main << Time <<"\n";
}
} // End of While Statement
return 0;
}