I can not get this input file to read

closed account (oN3k92yv)
I have it added to my resource file, but it keeps failing every single time

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	string tool;
	double unitCost;
	double numberOfUnits;
	double totalCost = 0;
	int counter;

	ifstream inFile;
	ofstream outFile;

	inFile.open("janeInventory.txt");

	if (!inFile)
	{
		cout << "Cannot open input file. Program Terminates! " << endl;

		return 1;
	}

	outFile.open("janeInventory.out");
	outFile << fixed << showpoint << setprecision(2);

	inFile >> tool >> numberOfUnits >> unitCost;

	while (inFile)
	{
		totalCost = numberOfUnits * unitCost;

	}

	cout << "**************************************************************************" << endl;
	cout << "Inventory for Jane Doe National Hardware " << endl;
	cout << "**************************************************************************" << endl;
	cout << endl;
	cout << "ITEM         NUMBER OF UNITS              UNIT COST ($)                  TOTAL VALUE " << endl;
	cout << "***************************************************************************" << endl;





}


http://i.imgur.com/bHVAzlz.png
Are you you trying to open the program from your home server or local computer? When I tried to run it from the server, I had the same issue about the UNC paths are not supported. The way I fixed mine was to use the Visual Studio's project in the local machine (i.e. C:\Users\whatever your user name\Documents\Visual Studio 2015\Projects\ConsoleApplication6).
Last edited on
closed account (oN3k92yv)
How do I do that? I'm trying to open it from my local computer, it's a text file on my notepad. How do I do what you did? I've been trying to get this fucking thing to read for the last 4 hours, it fails every single time.
Last edited on
closed account (oN3k92yv)
I'm new, so I have no idea how to change it to whatever it is that is making me get an error. this is where it's located

http://i.imgur.com/kkjUrR6.png

Steps
1. C Drive
2. Users
3. Your username folder on your local computer
4. Documents
5. Visual Studio 2015
6. Projects
7. ConsoleApplication6 (Based on the image you posted about your project)
8. ConsoleApplication6 (Again, it is inside of the folder ConsoleApplication6)
9. You should see a file named Source.cpp (Based on the image you posted about your project).
10. Place your janeInventory.txt folder there.

I know there is a shortcut for this, the key point is to ensure the txt file is in the same place as your .cpp file.


Nevermind, you did it
Last edited on
closed account (oN3k92yv)
Really? Why am I still getting the same error :-(
When you run your program, it is trying to run from a location called psf. Not your local computer. Let me look into it. Hopefully, someone would be able to guide you better.
Last edited on
closed account (oN3k92yv)
Could it be an error with parallels? It's what I'm running since I have a mac, and I came across this http://brandonbohling.com/2013/08/parallels-and-visual-studio-issue/
I am unfamiliar with MAC. I don't want to give you the wrong answer. However, that is what I meant. Maybe by "Simply create a symbolic on the Windows VM." Good luck!!!
You should take a look at https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934(v=vs.85).aspx if you have the file in the directory of your executable/project file- this will tell you where your program is trying to read from. Another tip- if you drag a file into your command window it will input the absolute path of that file. you can use your cin stream to grab the file path, then open the path that the user specifies instead of having a static file.

If you added your file to your resource files make sure you defined a link with an RC file, otherwise I would rely on the standard file system. If you don't have very much experience I would probably skip resources files, at least for now. They're super useful once you get your hands dirty, but as you can see they can cause a headache or two.
closed account (oN3k92yv)
whatever i give up
Last edited on
Bummer, hope you have a chance to make another crack at it. I bet you'll get some pretty hefty satisfaction when you finally complete your project.
Topic archived. No new replies allowed.