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

This is a discussion on Program That Searches For Flag "7e" in binary file within the C Programming forums, part of the General Programming Boards category; help would be much appreciated? havntdone C in a year and atthat it was only basic enough and new psycho ...

  1. #1
    ESP
    ESP is offline
    Registered User
    Join Date
    Apr 2006
    Posts
    2

    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);

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Code:
    while(huh2 = EOF);
    dwk

    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: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

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

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

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

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    > 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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    ESP
    ESP is offline
    Registered User
    Join Date
    Apr 2006
    Posts
    2
    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, 04: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 Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21