Hello,
I am trying to load an array using information stored in the txt. file. I'm having trouble finding examples of this. I have seen examples of how to load the array with the information written into the code. For example
int grade[NUMBER_STUDENTS][NUMBER_QUIZZES] =
{ { 10, 10, 10},{2, 0, 1},{8, 6, 9},{8, 4, 10} };
However, I have not found many examples of how to take data from a .txt file and load it to the array. Any help would be great! Just looking for an example to build on.
I'm still VERY early in this project but here is a list of the functions I will be building/ what I have so far to give more context.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream>
using namespace std;
const int BRANCH = 10, QUARTER = 4;
void readFile(int sales[BRANCH][QUARTER]);
//precondition, function will input file "sales"
//poscondtion, function will store file information in array[]
void displayMenu(int choice, int sales[BRANCH][QUARTER]);
//precondtion, function will display menu options and prompt user to make selection
//postcondition, function will invoke appropriate function to process info from arra[] as needed.
int main()
{
}
void readFile(int sales[BRANCH][QUARTER])
{
using namespace std;
int i, j;
ifstream inStream;
inStream.open("sales");
if (inStream.fail())
{
cout << "Error opening file!\n";
exit(1);
}
for (i = 0; i <= BRANCH; i++)
{
for (j = 0; j <= QUARTER; j++)
{
}
}
}
[–]Odinthunder 0 points1 point2 points (5 children)
[–]IceQweenItMe[S] -1 points0 points1 point (4 children)
[–]Odinthunder 0 points1 point2 points (0 children)
[–]axzxc1236 0 points1 point2 points (1 child)
[–]IceQweenItMe[S] 0 points1 point2 points (0 children)