error C2064: term does not evaluate to a function taking 1 arguments

Reply

Join Date: Mar 2006
Posts: 7
Reputation: mwo0002 is an unknown quantity at this point 
Solved Threads: 0
mwo0002 mwo0002 is offline Offline
Newbie Poster

error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #1
Mar 17th, 2006
Hi, I'm using Microsoft Visual C++ and I keep getting this error referring to this one line in my main file. The line of error is in bold.

Header file
[php]
int f (int n);

double e (double accuracy);

double exp (double expo, double exaccuracy);
[/php]

Computation file
[php]


#include "wong_header.h"

int f(int n)
{
int t = 1;
while (n >= 1)
{
t = t * n--;
}
return t;
}

double e (double accuracy)
{
accuracy = accuracy - 1;
double fac = 1;
double ee = 0;
while (accuracy >= 1)
{
fac = fac * accuracy;
ee = ee + (1/(fac));
accuracy--;
}
return ee;
}

double exp (double expo, int exaccuracy)
{
exaccuracy = exaccuracy - 1;
double value;
double fact = 1;
double exo = 0;
while ((expo >=0)&&(exaccuracy >=1))
{
value = expo * exaccuracy;
fact = fact * exaccuracy;
exo = exo + (value/fact);

exaccuracy--;

}
return exo;
}
[/php]


main file
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
using namespace std;
#include "wong_header.h"


int main()
{
	string command;
	int arg1;
	double earg2;
	double exarg4, exarg5;
	int result;
	double eresult, exresult;

	ifstream fin ("input.txt");	//reads from file input.txt
	if (!fin)					//checks input file 
	{	
		cerr <<"Cannot open the file input.txt\n";
		return 0;
	}

	ofstream fout("out.txt");	//output stream 
	if (!fout)					//check if output file 
	{							//was opened successfully
		cerr <<"Cannot open the file out.txt\n";
		return 0;
	}


	while(!fin.eof())	//it will read line after line until the program ends
	{
		fin >> command;

		int f = atoi (command.c_str());
		if (command == "f")
		{
			fin >> arg1;
			result = f(arg1);

			cout << "factorial of " << arg1 << "= " << result << "\n";
			fout << "factorial of " << arg1 << "= " << result << "\n";
		}

		else if (command == "!")
		{
		}

		else if (command == "e")
		{
			fin >> earg2;
			eresult = e(earg2);

			cout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
			fout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
		}

		else if (command == "exp")
		{
			fin >> exarg4, exarg5;
			exresult = exp(exarg4, exarg5);
			
			cout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
			cout << exresult <<"\n";
			fout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
			fout << exresult <<"\n";
		}
		else
		{
		}
	}
	fin.close();
	fout.close();

	return 0;
}

Can someone help me figure out what I'm doing wrong?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1437
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #2
Mar 17th, 2006
which line is in bold ? they all look bold to me. how about adding some comments that point to the line
... <<< this line is the error 

I think its better to use code tags when posting code, not php tags.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 7
Reputation: mwo0002 is an unknown quantity at this point 
Solved Threads: 0
mwo0002 mwo0002 is offline Offline
Newbie Poster

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #3
Mar 17th, 2006
Sorry, here it the main file again:

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
using namespace std;
#include "wong_header.h"


int main()
{
	string command;
	int arg1;
	double earg2;
	double exarg4, exarg5;
	int result;
	double eresult, exresult;

	ifstream fin ("input.txt");	//reads from file input.txt
	if (!fin)					//checks input file 
	{	
		cerr <<"Cannot open the file input.txt\n";
		return 0;
	}

	ofstream fout("out.txt");	//output stream 
	if (!fout)					//check if output file 
	{							//was opened successfully
		cerr <<"Cannot open the file out.txt\n";
		return 0;
	}


	while(!fin.eof())	//it will read line after line until the program ends
	{
		fin >> command;

		int f = atoi (command.c_str());
		if (command == "f")
		{
			fin >> arg1;
			result = f (arg1);//THIS LINE IS THE ERROR

			cout << "factorial of " << arg1 << "= " << result << "\n";
			fout << "factorial of " << arg1 << "= " << result << "\n";
		}

		else if (command == "!")
		{
		}

		else if (command == "e")
		{
			fin >> earg2;
			eresult = e(earg2);

			cout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
			fout << "e with the accuracy of " << earg2 << " is " << eresult<< "\n";
		}

		else if (command == "exp")
		{
			fin >> exarg4, exarg5;
			exresult = exp(exarg4, exarg5);
			
			cout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
			cout << exresult <<"\n";
			fout <<"The value of e^x with e being " <<exarg4<<" and x being " <<exarg5<< "is\n";
			fout << exresult <<"\n";
		}
		else
		{
		}
	}
	fin.close();
	fout.close();

	return 0;
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #4
Mar 17th, 2006
		int f = atoi (command.c_str());
		if (command == "f")
		{
			fin >> arg1;
			result = f (arg1);//THIS LINE IS THE ERROR

			cout << "factorial of " << arg1 << "= " << result << "\n";
			fout << "factorial of " << arg1 << "= " << result << "\n";
		}
Since you have a local variable called f, you can't call the function f(). Give them different names, like f_ret and func().
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 7
Reputation: mwo0002 is an unknown quantity at this point 
Solved Threads: 0
mwo0002 mwo0002 is offline Offline
Newbie Poster

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #5
Mar 17th, 2006
thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 7
Reputation: mwo0002 is an unknown quantity at this point 
Solved Threads: 0
mwo0002 mwo0002 is offline Offline
Newbie Poster

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #6
Mar 17th, 2006
Heh, that was post 100 for him. I feel so honored. It's not reading the input.txt file though. Where do I put the input fine so my program can read it?
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 482
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Solved Threads: 47
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #7
Mar 18th, 2006
Generally, your input.txt should go in the same place as your executable. If for some reason, this is causing you problems, or you do not know where the executable is, refer to the complete path of the txt file explicitly, for example, in DOS/Windows, you'd use

  1. ifstream fin ("C:\\MyProgram\\input.txt");
the double-backslash is necessary, since the file location is a string (and '\\' is the escape character for a single backslash)
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 7
Reputation: mwo0002 is an unknown quantity at this point 
Solved Threads: 0
mwo0002 mwo0002 is offline Offline
Newbie Poster

Re: error C2064: term does not evaluate to a function taking 1 arguments

 
0
  #8
Mar 18th, 2006
Thanks, but I already handed my project in... incorrectly. I probably got

probably (grade < 70)
{
cout << "Isuck because you failed" <<endl;
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC