#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
ofstream myfile;
int a[1000] = {0};
myfile.open ("Euler7.txt", ios::out | ios::app | ios::binary);
for (int i=0;i<1000;i++)
{
myfile << a[i];
cout << a[i] << endl;
}
myfile.close();
int c = 0;
for (int b=0;b>995;b++)
{
if (a[b]*a[b+1]*a[b+2]*a[b+3]*a[b+4] > c)
c = a[b]*a[b+1]*a[b+2]*a[b+3]*a[b+4];
}
cout << c << a;
return 0;
}
but everything i try to save just ends up being 0, the txt file is formatted like 651561561841351641351468746549, and i want to pull 1 digit intergers from it
ofstream That is the output stream. You are not "reading from", you are "saving to" this file. myfile << a[i]; Again, this is an output operation.
If you want to read ints without separators, you should read chars one by one and convert each to int.
Is this a problem to find maximum product of five consequent digits?