Thread: Program That Searches For Flag "7e" in binary file

  1. #1
    Registered User
    Join Date
    Apr 2006

    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!!
    const FLAG;
    enum FSMstate {SEARCH,
        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

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    while(huh2 = EOF);

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    New York
    Is that code in a function at all and variables defined somewhere? Also:

    if ( state == COPY_PLD && count = 8
    No closing parentheses. And

    huh2= fprintf(file_out_h, "%c", &shift[8]);
    It does not expect a pointer.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > Below is da code ive so far that is pullin about 4 errors and 4 warnings!!
    Is this the ACTUAL code you tried to compile, or merely just some random lines either typed in before pressing submit, or randomly copy/pasted from your source code in the hopes that it will make sense to us?

    > huh1 = fscaf(file_in_h,"%c",&bit_in);
    None of these variables are declared, and you can't spell fscanf

    > shift[i] = shift[i-1];
    Do you declare the array as shift[8] or shift[9] ?

    > shift[0] = bit_in
    Missing ;

    > if ( state == COPY_PLD && count = 8
    Missing ) and = should be ==

    There is no main function, nor any other kind of function.

    None of the variables are declared.

    You don't show how you're opening the files.

    Do you have an example of an input data file, because it seems like you're trying to convert say
    01000001 into say 'A'
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2006
    no it was template he gave us with some stuff extra added in ... that i typed out quickly one day hence the missin parenthesis and spellin mistakes

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  3. student binary file program....
    By Newworld in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 08:50 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM