I am new to this site, but I am really stuck on this problem. I tried looking at other forums and through my book and for some reason just can wrap my mind around this problem.
I dont know how to fill the array temp[days][time] with the input .txt file, temperatures.txt without messing up the days of the week. Also, the time has to be 1, 2, 3 ... up to 24. I know that as the array is, it will be 0 through 23. How do I make it so that it is 1 through 24.
I still have to write functions for this code, this is just a small part of it.
And this is what I have...
#include <iostream>
#include <array>
#include <fstream>
using namespace std;
const int days = 7;
const int time = 24;
int temp[days][time];
enum days {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
int main()
{
ifstream fin;
fin.open("temperatures.txt");
if (fin.fail())
{
cout << "Input file failed to open." << endl;
exit(1);
}
system ("pause");
return 0;
} // end of the main function
Thank you for the help! I apologize that this is such a dumb question, I am just very stuck and frustrated.
Well, making an array starting at 1 is kind of poor practice. I'd just keep it at 0, and when you need to display it, just display it as index + 1, and it'll display 1 to 24