Question
c++ please. I'm having trouble trying to input the contents of a txt. file into a 3 separate vectors to then be able to do
c++ please.
I'm having trouble trying to input the contents of a txt. file into a 3 separate vectors to then be able to do further calculations to the contents of the vectors. I just need help with the inputting of the contents of the txt file into vectors. I will leave an example of my text file below and my current code. Use whatever means necessary.
Example of my input file below:
1464815342.110273122787, 17.889999389648, 0.095994234085
1464815342.123246669769, 17.920000076294, 0.087267547846
1464815342.137223720551, 17.889999389648, 0.095994234085
1464815342.150209188461, 17.920000076294, 0.087267547846
1464815342.163207292557, 17.909999847412, 0.095994234085
1464815342.177282094955, 17.920000076294, 0.087267547846
1464815342.189191341400, 17.909999847412, 0.095994234085
1464815342.204182624817, 17.909999847412, 0.087267547846
1464815342.217026233673, 17.899999618530, 0.095994234085
1464815342.230037212372, 17.920000076294, 0.087267547846
1464815342.243027210236, 17.909999847412, 0.095994234085
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include
int main() {
string myString, line, FilterStatus; string timestamp, distance, angle;
vector
ifstream inFile("inputFile1.txt"); if (!inFile.is_open()) { cout
} ofstream outFile; outFile.open("file1Output.txt");
//getline reads in the entire first line //storing in line while (!inFile.eof() && inFile.peek()) {
while (getline(inFile, line)) {
getline(inFile, timestamp, ','); timestamp_v.push_back(stof(timestamp)); getline(inFile, distance, ','); distance_v.push_back(stof(distance)); getline(inFile, angle, ' '); angle_v.push_back(stof(angle));
outFile
}//end while
} inFile.close(); outFile.close(); return 0; }
The input log consists of a timestamp, followed by distance and then angle information. TTTTT.TTT, DD.DD, A. AAAStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started