Snippets out of context don't receive real answers.

What you mean. Is the not enough details there.

I can't compile your previous code and run it. If you could actually post the current code that demonstrates the issue you are facing, it would expedite the most correct answer.

Ok, here's the full code.

#include <iostream>
#include <fstream>
#include <limits>
#include <bitset>

using namespace std ;

int main()
{
	ofstream filebin ;
	filebin.open("RecordBinaryData.txt") ;

	ifstream file ( "path to binary file" ) ; 
	file >> noskipws ;
	typedef bitset< numeric_limits<unsigned char>::digits > bitset ;
        unsigned char byte ;
	long count = 0 ;
	
	if(filebin.is_open())
	{
		while( file >> byte )
		{
			//cout << bitset(byte) ; // to print bits as it is
			filebin << bitset(byte) ;
			count ++ ;
		}
		const long const_count = count ;
		long arr[const_count] ;

		filebin.close() ;
	}

	else
	{
		cout << "Unable to open the file.\n" ;
	}

cin.get() ;
return 0 ;
}

I have attached the binary file as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.