I am am taking data from a file and having the program output the numbers. The only thing I can not seem to do is get the program to skip the first line instead of skipping the first two lines. The second line contains data I need to be in the output window. I attached the one file I am extracting the data from.
My output is:
Enter the name of the file:J:\EngineData\A8.txt
The thrust for that engine is:
Time Thrust
0.084 2.115 It skips the first pair of digits in the file.
0.127 4.358 How do I fix this problem?
0.166 6.794
0.192 8.588
0.206 9.294
0.226 9.730
0.236 8.845
0.247 7.179
0.261 5.063
0.277 3.717
0.306 3.205
0.351 2.884
0.405 2.499
0.467 2.371
0.532 2.307
0.589 2.371
0.632 2.371
0.652 2.243
0.668 1.794
0.684 1.153
0.703 0.448
0.730 0.000
A8.txt
Code:// Include Section #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; // Main Program int main( ) { // Variable Declarations ifstream data; string file; double time; double thrust; cout << "Enter the name of the file:"; cin >> file; data.open(file); data.ignore(1000, '\n'); data >> time >> thrust; cout << "The thrust for that engine is: " << endl; cout << " Time Thrust" << endl; while(data >> time >> thrust) { cout << " " << setiosflags(ios::fixed) << setprecision(3) << time << " " << setprecision(3) << thrust << endl; } cout << "\n\nEnd Program.\n"; return 0; }