Using Visual Studio 2008...My assignment is to use the file SalesData.txt to load an array of structs, and use the array of structs to show to the screen a control-break report which breaks with each change in salesperson and shows each salesperson's total sales. I have not finished but I keep getting this error:
error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'const char [2]' (or there is no acceptable conversion)
This is what I have so far, but I can't get pass the error:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct salesTran {
string name;
string type;
string style;
double price;
double quantity;
};
ostream& operator << (ostream& os, salesTran purchase)
{os << purchase.name << "\t" << purchase.type << "\t" << purchase.style << "\t" << purchase.price << "\t" << purchase.quantity;
return os;}
istream& operator >> (istream& is, salesTran purchase)
{is >> purchase.name >> "\t" >> purchase.type >> "\t" >> purchase.style >> "\t" >> purchase.price >> "\t" >> purchase.quantity;
return is;}
int main()
{
ifstream indata;//input file stream
indata.open("SalesData.txt");
salesTran purchase[75];
int subtotal=0;
for(int x=0;x<75;x++)//input loop
{
indata>>purchase[x];
}
for(int y=0;y<75;y++)//compute & output loop
{
cout << purchase[y].name;
cout << purchase[y].type;
cout << purchase[y].style;
cout << purchase[y].price;
cout << purchase[y].quantity;
}
for(int z=0;z<75;z++)
{
cout << purchase[z]; cout << "\t" <<purchase[z].quantity*purchase[z].price << endl;
}
indata.close();
return 0;
}