I have an assignment where I'm given a file containing dates in numbered format and I have to have a program read the file and spit out days of the week for each date give. Each line of the file is a separate date. My go-to method was an eof loop. However, my file has 10 dates, and my output has 30. Here is my main for context.
int main()
{
ifstream inFile;
inFile.open("/Users/holdentatlow/Desktop/date 2");
const char *Names[] = {"Sunday","Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
int day = 0;
int date;
inFile >> date;
cout << "Day : " << Names[day] << endl;
while (!inFile.eof()){
inFile >> date;
day = getWeekDay(date, date, date);
cout<< "Day : "<< Names[day] <<endl;
}
inFile.close();
return 0;
}
also, I get the impression that the dates it does report aren't entirely accurate. I don't have the resolve to check each one individually but the results seem erratic enough to not be simply repeated.
here's the file I'm taking dates from
0 10 1900
2 16 1900
1 2 1944
0 1 2004
1 29 2004
11 24 2002
6 2 2050
2 23 2004
0 6 1812
1 3 1800