Program That Searches For Flag "7e" in binary file
help would be much appreciated? havntdone C in a year and atthat it was only basic enough and new psycho lecture for communications wantin this programme writtin in C!!
Basically he wants us to make a binary file, i.e a .dat file. Then you write a programme that opens the file, reads the data, stores it and searches it for the 7E or rather it's binary version. Then u print the"7e" to the screen not the file itself!!
Below is da code ive so far that is pullin about 4 errors and 4 warnings!!
thanks
Code:
#include<stdio.h>
const FLAG;
enum FSMstate {SEARCH,
FOUND_FLAG,
COPY_PLD,
FINAL
};
do
{
huh1 = fscaf(file_in_h,"%c",&bit_in);
for (i =8; i >0;i--)
{
shift[i] = shift[i-1];
}
shift[0] = bit_in
if (shift == FLAG)
{
if (state == SEARCH)
{
state = FOUND_FLAG;
}
if ( state == COPY_PLD && count = 8
{
state = FINAL;
}
}
if (state ==FOUND_FLAG && count = 8
state = COPY_PLD;
if (state == COPY_PLD)
huh2= fprintf(file_out_h, "%c", &shift[8]);
if (state == FINAL)
{
state = SEARCH;
}
if (state == FOUND_FLAG || state == COPY_PLD)
{
if(count==8) counter = 0;
else count ++;
}
while(huh2 = EOF);
//close files
fclose(file_in_h);
fclose(file_out_h);