Hi,
I have come up with the source code to read files. However, this is source code reads the file 1024 bytes at a time. I would like to modify the code to read it byte by byte.
This code wants to determine if 001 bytes ( oo oo o1 hex) is present in the file.
I wish to eliminate the use of buffer. Can someone kindly guide me please? Thank you very much.
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
FILE *stream = fopen("Celine.jpg","rb");
char buffer[1024];
int bytesRead;
bool startPrefixFound;
while (bytesRead = fread( buffer,1, 1024, stream))
{
startPrefixFound = false;
for (int i = 0; i < bytesRead-3; i++)
{
if (buffer[i]==0)
{
if (buffer[i+1]==0)
{
if (buffer[i+2]==0)
{
if (buffer[i+3]==1)
{
startPrefixFound = true;
printf("001 bytes found. May be H.264 file type");
break;
}
}
}
}
}
if (startPrefixFound) break;
printf("001 bytes not found. Definitely not H.264 file type");
break;
}
cin.ignore();
cin.get();
return 0;
}