Function Does not take 4 arguments Error

closed account (365X92yv)
Here's the code and the error I'm having. I'm sure there are more simplified ways of writing this code but right now I just want to fix the error. Also, this code I can't test because of the error but I can tell you the goal of this function. I want it to get input of a fraction problem, i.e 1.2 - 1/4, and be able to solve it. I still need to figure out how to get rid of the space between the first fraction, the second one, and the sign operator but thats not a big issue right now. Below is my code. Please help me fix the "does not take 4 arguments" error.

CODE:

void fractionReader()
{
char spacer1;
char spacer2;
char signRead;
int fracNum1, fracDen1;
char fracSign1;
cout << "Input: ";
cin >> fracNum1 >> fracSign1 >> fracDen1;
cout << fracNum1 << fracSign1 << fracDen1 << endl;

cin.ignore(1, ' ');
signRead = cin.get();
cout << "Sign = " << signRead << endl;

int fracNum2, fracDen2;
char fracSign2;
cin >> fracNum2 >> fracSign2 >> fracDen2;
cout << fracNum2 << fracSign2 << fracDen2 << endl;

// Variables for +, - parts
int newFracDen;
int newFracNum1, newFracNum2;
int finalNumerator;

// Figures out the new denominator for the fractions, provided the two denominators are not equal
if(signRead == '+')
{
newFracDen = fracDen1 * fracDen2;
newFracNum1 = fracNum1 * fracDen2;
newFracNum2 = fracNum2 * fracDen1;
finalNumerator = fractAdd(newFracNum1, newFracNum2);
}
else if(signRead == '-')
{
finalNumerator = fractSub(newFracNum1, newFracNum2);
newFracDen = fracDen1 * fracDen2;
newFracNum1 = fracNum1 * fracDen2;
newFracNum2 = fracNum2 * fracDen1;
}
else if(signRead == '*')
{
fractMult(fracNum1, fracNum2, fracDen1, fracDen2);
cout << "The fraction result is: " << newFracNum1 << "/" << newFracDen << endl;
}
else // needs work
{
fractDiv(newFracNum1, newFracNum2);
}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Checks to see if the fraction is equal to 1
if(finalNumerator == newFracDen)
{
finalNumerator = 1;
cout << "The fraction result is: " << finalNumerator << endl;
}
else
{
cout << "The fraction result is: " << finalNumerator << "/" << newFracDen << endl;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
}

It would help if we knew what line the error was on.

Also, the error sounds pretty self-descriptive. You're trying to pass 4 parameters to a function that doesn't take 4 parameters.

I don't see where you're passing 4 params to any function in this code, so the error likely isn't anywhere in the pasted code.
Last edited on
Two things:

1) [ code ] and [ / code ] makes this much easier to read, as well as indenting.

2) Post the code that calls this function, as well as any function prototype that you might have used.
closed account (365X92yv)
Oh wow I'm a dumbass. I forgot to go back and fix my prototypes. Thanks guys. I'm such a noob at C++.
Last edited on
I wouldn't spend too much time beating yourself up about it. I spent half an hour yesterday writing code, and as soon as I compiled it, I had to go back and put semicolons on the end of two of the lines. It happens to everyone, just laugh and learn.
Topic archived. No new replies allowed.