Hey guys i have a header file and now i am writing the implementation file and defining the constructors..i am having trouble with 1 but..
void bitmap:save (string filename)
{
}
//The bitmap representation is written to filename. The bitmap file will consist of two positive integers R and C representing the number of rows and columns followed by R rows of C columns of zeroes and ones. For example :
3 5
00000
00000
01100
//i have to save it into string file name
can anyone plz help me
void bitmap::save (string filename) const
{
ofstream outFile(filename.c_str());
if (myfile.is_open())
{
outFile << numrows;
outFile << numcols;
for (int r = 0; r < numrows; r++)
{
for (int c = 0; c < numcols; c++)
{
//asuming you have your data in a 2D array
//I'll also assume that the data member is called data
outFile << data[r][c];
}
}
}
else
{
cout <<"Failed to open file" << cout;
}
outFile.close();
}