so this really got me i, i have to write the numbers to an array then to the file, all i keep getting is numbers 0-99 however in the file help would be greatly appreciated.
#include <iostream>
#include <fstream>
using namespace std;
bool isPrime(int c);
void write_array(int x, ofsteam &outfile);
void write_prime(int num, int p);
int main()
{
int p = 0;
int count;
const int arrays = 100
ofstream pfile("Prime.txt"); //Declare variables
for (int c =0; c<100,c++) //Write all the arrays to 0
arrays[c]=0;
for (int x = 2; x < 100; x++) //Finding The Prime Numbers
{
if(isPrime(x))
{
write_array(x, pos); //Writing Primes to Array
pos++
}
}
for(count = 0; arrays[count] != 0; count ++) //Write arrays to file
write_prime(arrays[count],pfile);
pfile.close();
return 0;
}
bool isPrime(int c)
{
for (int y = 2; y < c; y++)
{
if(c % y == 0)
{
return false;
break;
}
}
return true;
}
void write_prime(int p, ofstream &pfile)
{
pfile << p << endl;
}
void write_array(int num, int p)
{
arrays[p]=num;
return;
}