Help with error?
Jan 29, 2014 at 1:08am UTC
I'm getting an error on line 15. It says "'doCalculation': identifier not found". Any idea what I'm doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#ifndef CHECK_H_
#define CHECK_H_
#include <iostream>
#include <fstream>
using namespace std;
void checkFile ( istream & infile )
{
string tempString;
if ( infile >> tempString )
{
doCalculation ( infile );
}
else
{
cout << "primes: 0 The file you entered is empty" ;
}
}
void doCalculation ( istream & infile )
{
while ( true )
{
int a, b, i, j, k, primecount;
if ( infile.fail() )
{
break ;
}
infile >> a >> b;
for ( i=a; i<=b; i++ )
{
for ( j=1; j<=i; j++ )
{
k = i % j;
if ( k = 0 )
{
primecount++;
}
}
}
cout << a << " " << b << " primes: " << primecount << endl;
}
}
#endif
Jan 29, 2014 at 1:14am UTC
Rearrange the order of the functions, or declare a prototype for doCalculation before you define checkFile. This isn't Java, you know - order matters ;)
Jan 29, 2014 at 1:24am UTC
Many thanks :)
Topic archived. No new replies allowed.