So I have a class:
class myClass {
public:
void readFile();
private:
int sPerDay[10];
};
And I want this function to read/print the array of the text file (a bunch of numbers 10 lines long)
void myClass::readFile()
{
ifstream read("numbers.txt");
for(int i=0;i<10;i++)
read>>sPerDay[i];
for (int i = 0;i<10;i++) {
cout << sPerDay[i];
}
}
Output is a bunch of random numbers. Where am I going wrong?