I am having issues printing the prime numbers from the calPrimes function to a text file. It prints out fine on the screen, but only writes the first number in the text file. I'm also having a hard time printing the numbers that have been evaluated to a file or the screen.:
void PrimeClass::calPrimes(){
int num=PrimeClass::getNum2();
ofstream outdata;
bool test=true;
for ( int i = 2; i <= num; i++){
for ( int j = 2; j <i; j++){
if ( i % j == 0 ){
test=false;
}
}
if (test){
cout << i << "\n";
outdata.open("prime.txt");
outdata << i;
}
test=true;
}
outdata.close();
}