Solved
compiling errors
Posted on 2003-10-25
here is my code, I'm getting 3 errors and can't seem to figure out what is causing them, I'm using Visual Studio .NET as the compiler.
GCD.cpp(28) : error C2144: syntax error : 'int' should be preceded by ')'
GCD.cpp(28) : error C2660: 'computegcd' : function does not take 0 parameters
GCD.cpp(28) : error C2059: syntax error : ')'
#include <iostream>
#include <fstream>
using namespace std;
int computegcd (int m, int n);
main()
{
int r, n, m;
int count =1;
int mtemp, ntemp;
int gcd;
ifstream infile;
ofstream outfile;
infile.open("datafile.dat");
outfile.open("gcdlist.dat");
while (infile)
{
//outfile << "Enter first integer ";
infile >> m;
outfile << "\nThe first integer is: " << m << endl;
//outfile << "Enter second integer ";
infile >> n;
outfile << "The second integer is: " << n << endl;
this is line 28 gcd = computegcd (int m, int n);
outfile << "\nThe GCD is: " << gcd << endl;
outfile << "\n";
outfile << "\n";
}
infile.close();
outfile.close();
return 0;
}
int computegcd (int m, int n)
{
int r, ntemp, mtemp;
if (m < n)
{
ntemp = n;
mtemp = m;
m = ntemp;
n = mtemp;
}
r = n % m;
while(r != 0)
{
n = m;
m = r;
r = n % m;
}
return m;
}
thanks for the help