homework troubles

So I have been working on this mess for hours and I have no clue what I am doing wrong. I am trying to open this text file(the text file is there), but it just will not open for some reason. Am i doing something wrong here?

#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>

using namespace std;

int main()
{
ifstream inData;
ofstream outData;
string item=string();
int cost=int();
int units=int();
int total=int();


cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"\tInventory Report For Malik Anderson International Hardware"<<endl;
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;

cout<<"ITEM NUMBER OF UNITS UNIT COST($) TOTAL VALUE($)"<<endl;
cout<<"________________________________________________________________________________"<<endl;

inData.open("inventory.txt");

if (!inData)
{
cout << "Unable to open file inventory.txt";
exit(1); // if data is not found, call system to stop
}

if (inData.is_open())
{
while(!inData.eof())
{
total=units*cost; //stating what equals to total

inData.ignore(1,'\n');

inData>> left >> item >> " " >> right >> " " >> units >> " " >> cost >> " " >> total;
}
}






inData.close();









return 0;
}
Please use code tags.
http://www.cplusplus.com/articles/z13hAqkS/

this line is wrong inData>> left >> item >> " " >> right >> " " >> units >> " " >> cost >> " " >> total; should look like this inData >> item >> units >> cost >> total I'm assuming that total is in the file and not something you have to calculate after the data is input.

I commented that line out and it worked fine for me. The file path you are using will only work if the txt file is saved in same folder as your project.
Thanks for the tip about the code tags. And yes, the txt file is in my project folder but it still won't freakin open. I even directed it to the desktop and it still would not work.
Give this a try just to see what happens.
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
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
	ifstream inData;
	ofstream outData;
	string item = "";
	double cost = 0;
	int units = 0;
	double total = 0;

	outData.open("testFile.txt");
	outData << "TestString" << " " << 2 << " " << 14.99 << " " << 29.98 << endl;
	outData.close();

	inData.open("testFile.txt");

	if (!inData) 
	{
		cout << "Unable to open file";
		cin.ignore();
		exit(1);
	}
	inData >> item >> units >> cost >> total;

	cout << item << " " << units << " " << cost << " " << total;
	
	inData.close();
	cin.ignore();
	return 0;
}


output should be
TestString 2 14.99 29.98
Topic archived. No new replies allowed.