Help with ifstream / inFile please :)

Okay, first of all, I would like to thank anyone for actually opening my topic thread! :)

Now, on to the important matters...
I am completely stuck on this application!
I feel as if my coding is on-point, but my application is not able to recognize inFile's, or anything of this sort.
I'm not going to lie either.. I am absolutely CLUELESS, as how to do this.

When I run my application, it asks for the user to input a file name.
...What file name?
Am I supposed to create said file? or does the application create one itself?
I'm not asking for the flat-out answer. I would def love to be pointed in the right direction though. :)

Every time I ask someone, they can't tell me what to do. :(

Hopefully someone experienced is up to the task?! :)
Please and thank you!


ps; this application is to record grades.

-----------------------

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>

using namespace std;

int main()
{

ifstream inFile;
char answers [20];
string id;
char response;
char fileName [25];
int testScore;

cout << "A program that works with arrays and loops" << endl;

cout << "Enter the input file name: ";
cin >> fileName;

inFile.open (fileName);

if (!inFile.is_open())
{
cout << "Unable to open the input file.";
system("pause");
exit(1);
}

cout << "\n ID Answers Sc Gr";

for (int i=0; i<20; i++)
inFile >> answers [i];

while ( (inFile >> id) != NULL)
{
cout << "\n" << id << " ";

inFile.get(response);

testScore = 0;

for (int i = 0; i < 20; i++)
{
inFile.get (response);

cout << " " << response;

if (response == ' ')
testScore += 0;
else
if (response == answers [i])
testScore += 2;
else
testScore += -1;
}

cout << " " << testScore << " ";

double p = testScore * 2.5;

if (p >= 90)
cout << 'A';
else
if (p >=80)
cout << 'B';
else
if (p >=70)
cout << 'C';
else
if (p >=60)
cout << 'D';
else
cout << 'F';
}

return 0;
}
Topic archived. No new replies allowed.