Question: Bookmark I have an assignment due soon and it involves importing data from a .txt file. There are three rows of data, each row contains
Bookmark I have an assignment due soon and it involves importing data from a .txt file. There are three rows of data, each row contains 10 numbers, and all of the data are integers. I understand the concept of importing string line by line with the getline statement, but am unsure how to import data by walking through each line to import each number individually.
heres what i have:
void importData(string filepath, int runnerData[][10], int &runnerCount) {
ifstream inFile; inFile.open("Input.txt"); //This function reads the numbers from the file into the array while
(!inFile.eof()) {
for (int runnerCount = 0; runnerCount < 10; ++runnerCount) {
for (int col = 0; col < 10; ++col) { cout << runnerData[runnerCount][col] << " "; //this i was using as a test to see what was outputting
}
}
inFile.close();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
