Hi,
I need to read repeatedly data from a MPEG2 file to the buffer of 188 bytes and analyse data bit by bit.

I have the problem with correct bytes reading from file. In my code listed below I have two methods for that.

First one is lossing this bytes which in hex_base mode have 0 at the begining, eg: 03, 0F, etc.

The second method based on read function which need to have buffer as a char (lenght > 1 byte). Because of that I receive different values from that from file in some cases.

How can I properly read such file? Any ideas?

Code:
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <windows.h>

using namespace std;

int main()
{
 fstream plik_in;

 const int TS_LEN=188;

 //bufor do pierwszej metody
 byte buffor[TS_LEN];
 byte bajt;

//bufor do drugiej metody
char buffor2[TS_LEN];

//plik do obrobienia
char path1[40]= "TEST2.ts";

//otwieram plik
plik_in.open( path1 ,ios::in|ios::binary/*|ios::dec,|ios_base::showbase*/);
 
 if(!plik_in)
 {
  cout << "Problem z plikiem wsadowym\n";
 }

 // 1 METHOD
 for(int i=0;i<TS_LEN;++i)
 {
	 plik_in >> bajt;
	 buffor[i]=bajt;
	 cout << "buffor[" << i <<"]: " << hex << (int)buffor[i] << endl;
 } 
 plik_in.close(); 


  // 2 METHOD
 //otwieram plik
plik_in.open( path1 ,ios::in|ios::binary/*|ios::dec,|ios_base::showbase*/);
std::cout << "Reading " << TS_LEN << " characters...\n ";

    // read data as a block:
    plik_in.read (buffor2,TS_LEN);

	for(int i=0;i<TS_LEN;++i)
	 {
		 cout << "buffor[" << i <<"]: " << hex << (int)buffor[i] << endl;
	 } 

plik_in.close();

system("PAUSE");
}