I need help creating a program. I have a text file that is 0's and 1's which create a picture. There are 33 rows and 50 columns. Every row contains 0's and 1's. what i need to do is do a program that will read the zeroes and ones and display it as follows: 2 4 5 2 9, this on my text file would show 0011110000011000000000. This is what i have so far but it is not working
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string filenameIn="house.txt";
string filenameOut="casa.txt";
const int elements = 1650;
int i, house[elements], count = 0;
double avg;
ifstream inFile;
ofstream outFile;
inFile.open(filenameIn.c_str());
outFile.open(filenameOut.c_str());
if (inFile.fail())
{
cout<<"\nThe file was not successfully opened."
<<"\nPlease check that the file currently exist."<<endl;
exit(1);
}
if (outFile.fail())
{
cout<<"The out file was not successfully opened."<<endl;
exit(1);
}
inFile>>house[elements];
if(inFile.good())
{
for (i = 0; i < elements; i++)
if(house[i]!=house[i+1])
outFile<<house[i];
count++;
}
return 0;
}