-
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.
-
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.
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.
-
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.