Thread: How to edit hex file using C++

  1. #1
    Registered User
    Join Date
    Apr 2012
    Posts
    1

    How to edit hex file using C++

    I have one hex file I want to edit my hex file using C++.
    My hex file look like this AA550D0AAA55780000AA04010006000D3FF8126239150000A0 000401000F00AA550D0AAA55710000AA04030005000D3FF812 6239154000C0000403010F082103000911000940043FF88F7F 0009AA550D0AAA55760000E83F0F0089200500002058000089 403800001F7A1600100089FFFF1F00101000020A04020B234D 00003FFF1F7B1C0010008940001F000303004201139D234902 02FE4E230000E2020000AA550D0AAA55720000E83F0F008340 1F00001F5D1C0010008340001F00030300422F13BD23490202 FE4E2300000B100000AA550D0AAA557E0000E83F0F00872005 00002078000087401F00001FFD1C0010008740001F00030300 4284126323480202FE5223000064110000AA550D0AAA557900 00E83F0F0080200500002078000080401F00001F6C1C001000 8040001F00030300424C13D923490202FE52230000DB2E0000 AA550D0AAA55760000E83F0F007B401F00001F721C0010007B 40001F0003030042C4128223490202FE512300006B100000AA 550D0AAA557D0000E83F0F007E401F00001F351C0010007E40 001F0003030042EE120124490202FE52230000281C0000AA55 0D0A
    AA55740000E83F0F0088401F00001FCB1C0010008840001F00 03030042EC129C23490202FE50230000AD260000AA550D0AAA 556F0000AA04030005


    I just want to make new line after every '0D0A'

    thanks in advance.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    0D0A is a newline character. You want another newline character?

    It sounds like what you have is a text file of hexadecimal like characters and not a binary file. If that is the case, you can read the entire file into a string and do a find/replace of all "0D0A" with "0D0A\n".
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    So show us the code you're written already and we'll help you out.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Handling -Read write and edit a file
    By aprop in forum C Programming
    Replies: 3
    Last Post: 02-27-2010, 02:01 PM
  2. Edit a .dat file.
    By spikestar in forum C Programming
    Replies: 1
    Last Post: 10-10-2009, 03:59 PM
  3. edit txt file help
    By pczafer in forum C++ Programming
    Replies: 4
    Last Post: 04-20-2009, 07:49 AM
  4. How to edit a .txt file in C++
    By hmoleman in forum C++ Programming
    Replies: 9
    Last Post: 11-10-2008, 10:58 PM
  5. how to edit *.cpp file in VC++.net?
    By Jasonymk in forum C++ Programming
    Replies: 1
    Last Post: 01-06-2003, 04:42 AM