Hey, my name is Alberto i am just starting to lear all about programming with C++ and one of my assignments is to open a file data1.txt into the program using ifstream inData where inData is the name of the variable for my file.
the problem i have found is that when i am trying to open the file and read the data it gives me a lot of erros. if someone can help me, by telling me what is my erro i would apriciate it.
this is what i have so far:
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int main ()
{
int item1, item2, item3;
double count1, count2, count3;
double price1, price2, price3;
double itemTotal1, itemTotal2, itemTotal3;
long double totalInventoryValue;
totalInventoryValue = totalCount * totalItem;
totalCount = count1 + count2 + count3;
totalItem = item1 + item2 + item3;
ifstream inData;
inData.open("C:\\data1.txt");
inData >> item1 >> price1 >> count1;
getline (cin, item1);
getline (cin, price1, count1);
cin.ignore(100, '\n');
return 0;
}
and this is my file-data: "data1.txt"
1Gig DDR2 Memory
35.55 120
2Gig DDR2 Memory
48.99 60
19" Shart LCD Monitor
345.95 25