Question: I am using Dev++ for my C++ class and I cant get any of my text files to open up in my programs. What am

I am using Dev++ for my C++ class and I cant get any of my text files to open up in my programs. What am I doing wrong? here is an example from one of my programs.

int main() {

// creating a input file stream ifstream ifile;

// opening the file containing student's records ifile.open("./grade.txt");

string line; int count = 0; while (getline(ifile, line)) count++;

ifile.close();

ifile.open("./grade.txt");

// create a vector of students to hold student info

vector students;

// verify the file is opened if (ifile.is_open()) { string fname, lname; int test1, test2, assign1, assign2, assign3, assign4, atten; for (int i = 0; i < count; i++) { ifile >> fname >> lname >> test1 >> test2 >> assign1 >> assign2 >> assign3 >> assign4 >> atten; students.push_back(Student(fname, lname, test1, test2, assign1, assign2, assign3, assign4, atten)); } } else { cout << "File not opened!" << endl; return -1; } }

I have tried both ./grades.txt and just grades.txt.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!