TOO many Arguments to Function Call

I keep getting this error and i am not sure how to fix it..
:24: too many arguments to function `Car GetCar (ifstream &)'
:48: at this point in file
Below is the code
--------------
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

struct Date
{
int month;
int day;
int year;
};

struct Car
{
float price;
Date purchased;
string customer;
};

Car GetCar(ifstream &dataIn);
// Pre: File dataIn has been opened.
// Post: The fields of car are read from file dataIn.

void WriteCar(ofstream& dataOut, Car car);
// Pre: File dataOut has been opened.
// Post: The fields of car are written on file dataOut,
// appropriately labeled.

int main ()
{
Car car;
ifstream dataIn;
ofstream dataOut;

dataIn.open("cars.dat");
dataOut.open("cars.out");


car = GetCar(dataIn);
while (dataIn)
{
car.price = car.price * 1.10;
WriteCar(dataOut, car);
GetCar(dataIn, car);
}
return 0;
}

//*****************************************************

Car GetCar(ifstream& dataIn)
{
Car car;
dataIn >> car.customer;
dataIn >> car.price >> car.purchased.day
>> car.purchased.month >> car.purchased.year;
dataIn.ignore(2, '\n');
return car;
}

//*****************************************************

void WriteCar(ofstream& dataOut, Car car)
{
dataOut << "Customer: " << car.customer << endl
<< "Price: " << car.price << endl
<< "Purchased:" << car.purchased.day << "/"
<< car.purchased.month << "/"
<< car.purchased.year << endl;
}
GetCar(dataIn, car);
It looks like you meant car = GetCar(dataIn);.
so i did make that correct and ran the program but nothing happens. Is that what is supposed to happen? Cause the question is, what is written on file Cars.out.
> Is that what is supposed to happen?
It's your code, ¿what do you want to happen?

> Cause the question is, what is written on file Cars.out.
¿did you have a `cars.out' file?
¿can you open it?
¿can you read it?

¿Did you have a `cars.dat' file?
Try checking the where you put the Cars.out and Cars.dat files. They should be in the same directory as the executable of your program.
There is a lack of symmetry between the functions which write to and read from the file.

The Write function WriteCar() outputs data like this:
Customer: Fred
Price: 2000
Purchased:25/11/2016
Customer: Suzie Soo
Price: 3000
Purchased:28/2/2015

But the read function GetCar() expects data in a format like this:
Fred
2000
25 11 2016
Suzie_Soo
3000
28 2 2015


If you want them to work together nicely, you'll need to decide on a specific data format and use it for both read and write. And modify one or both functions accordingly.
perhaps the program is intended to translate from one format to the other.
Also, the price is updated.
OP: instead of WriteCar(), GetCar() consider overloading the insertion and extraction operators
Topic archived. No new replies allowed.