So I am writing code which should read a .txt file and use the users input to find various things. IM currently just trying to get the program to enter a while loop I thought should read the file. Can anyone point me to why this isn't working?
I just have it printing "hi" to see if it works for now.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream din;
int team;
din.open ("SEC-2011.txt");
cout << "Which SEC team would you like the record of?" << endl;
cout << "1 for Arkansas" << endl;
cout << "2 for Alabama" << endl;
cout << "3 for LSU" << endl;
cout << "4 for Mississippi State" << endl;
cout << "5 for Ole Miss" << endl;
cout << "6 for Tennessee" << endl;
cout << "7 for Auburn" << endl;
cout << "8 for Georgia" << endl;
cout << "9 for Vanderbuilt" << endl;
cout << "10 for South Carolina" << endl;
cout << "11 for Florida" << endl;
cout << "12 for Kentucky" << endl;
cin >> team;
int s1;
int s2;
string team1;
string team2;
while (din >> s1 >> team1 >> s2 >> team2)
{
if (team == 1)
{
cout << "Hi" << endl;
}
if (!din) {
cout << "Error: Could not open file. " <<
"Make sure your file is in same place as executable file " <<
"or in whatever the \"working directory\" of your IDE is set to" << endl;
}