Access is denied?

Nov 13, 2015 at 5:47am
When I debugged it, the error said that it was unable to start the program and access was denied. Here's the homework problem:


Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as
descried in the details below. The program should display the menu until the user selects the menu option quit.

I did save the exam.txt file in my computer. It has the following numbers inside the file:
"10 20 30 40 50 60 70 80 90 100"
those are the only numbers in the file.

I want the program to read this file but I couldn't get it done because of this error. What exactly did I do wrong?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <fstream>        
#include <string>
using namespace std;

int main()
{
	ifstream inputFile;
	string score;

	
	inputFile.open("exam.txt");

	cout << "Reading the score from the file.\n";

	inputFile >> score;      
	cout << score << endl;


	inputFile.close();      
	return 0;
}
Nov 13, 2015 at 6:45am
What OS are you using? Also, have you try resetting your IDE? It's possible the text file is still running.
Last edited on Nov 13, 2015 at 6:50am
Nov 13, 2015 at 8:08am
I know this happens to me on Visual Studio if you're on the debugger for too long.
Nov 14, 2015 at 4:36am
Oh cool, Cody was right. I reopened the program again and it can display words on the console window.

The thing is, it only shows "Reading the score from the file" on the console window besides the numbers "10 20 30 40 50 60 70 80 90 100" from the exam.txt file. How can I fix this?
Topic archived. No new replies allowed.