I've had problems opening files in C++ since day one, and I'm running into the problem of getting specific files open again. Am I doing something wrong? I've tried this part with and without the ".txt" after it, as well as placing it into the C drive and just trying to get it that way, but it still doesn't work.
Code:
ifstream correctAnswers;
ifstream studentAnswers;
correctAnswers.open("C:\CorrectAnswers");
studentAnswers.open("C:\StudentAnswers");
if (correctAnswers && studentAnswers) {
for (int i = 0; i < SIZE; i++) {
correctAnswers >> answerKey[i];
studentAnswers >> studentKey[i];
}
}
else {
cout << "error" << endl;
}
The error part keeps showing, so I'm assuming it means the files haven't opened or the files' contents would be copied into the array.