Thread: hexdump issues

  1. #1
    Registered User daluu's Avatar
    Join Date
    Dec 2002
    Posts
    42

    hexdump issues

    Hi, I have 2 issues that I'd like to be addressed.

    The main issue is that my "c/c++" hexdump program appears to work on the server but compared to a perl hexdump script, I find it skips the first byte in a file. Can you please review my c/c++ code and see what logic errors I may have. I can't find any offhand at this point. the urls below contain my source code. if you need me to post it here, let me know, trying to save space here.

    "my C/C++ hexdump program"
    http://www.engr.sjsu.edu/daluu/hexdmp.cpp.txt
    "the perl hexdump script I used to compare with"
    http://www.engr.sjsu.edu/daluu/hexdump.pl.txt

    if anyone has additional time I have two more issues to ask:

    1)the program runs fine (except for error listed above) on a Sun Solaris server, but it crashes in Windows 2k with this message:

    instruction at "0x004137fd" referenced memory at "0x00000004". memory can't be written.

    why does it do that? the code is built for unix testing but should be cross-platform, i believe.

    urgent help needed. thanks in advance for help.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Pick one. C or C++. Stop using both. To be exact, stop mixing your stream types. Either use the cin/cout, or use the standard C types.

    Your get byte function isn't needed. Make it an inline function or a macro if you don't like having the extra paremeters in your fgetc. Really though, there is no point in having it at all.
    Code:
    while (!feof(fp))
    Don't use feof. Check the data read for EOF and use it instead. It's much better. Your text dump is way more compilicated than it needs to be.

    Again, stop mixing stream types.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User daluu's Avatar
    Join Date
    Dec 2002
    Posts
    42
    i know I shouln't mix c/c++ code but I started out learning C++ and the hexdump samples I've seen were in C so I started off in a mix of code. I'll standardize the code along the way.

    and regarding the gety_byte function. I have to make use of a buffer for the final program as an assignment. So currently, the get_byte function serves as a driver (or is it called stub, i forget) for the final function it is supposed to be.

    thanks for your advice though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. iterator issues
    By Elkvis in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2009, 09:52 PM
  2. Replies: 22
    Last Post: 12-23-2008, 01:53 PM
  3. issues in float division a/b
    By George2 in forum C# Programming
    Replies: 17
    Last Post: 04-24-2008, 06:15 AM
  4. Speed issues
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-22-2005, 03:06 AM
  5. Hexdump...?
    By ylph82 in forum C Programming
    Replies: 5
    Last Post: 06-04-2002, 12:33 AM