Usage of Hext Dump in C programming

M

Matt

I want to know what is Hex Dump? I tried to search in google but
didn't get useful results. I know it is the hexademical representation
of something. But I don't know what is something? From C programmer's
perspective,
I always hear this term. But when do we need to use hex dump? what's
the importances of hex dump?

please advise. thanks!!
 
E

Emmanuel Delahaye

Matt wrote on 29/07/04 :
I want to know what is Hex Dump?

It has nothing do do with C programming. It's just a way of
representing some memory area. Hex stands for 'hexadecimal', I presume.

FOr example, say that we have an int with the value 0x1234:

int n = 0x1234;

an 'hex dump' of n will give the memory representation of the value on
the current platform.

For example:

"34 12" on a x86 16-bit
"34 12 00 00" on a x86 32-bit
"00 00 12 34" on a 68000

etc.

Of course you can write a C-function that does the job of converting
the data area (address, length) into an hexadecimal representation.

void hexdump (void *p_data, size_t length)
{
/* now it's your turn to work on! */
}
 
R

Richard Bos

I want to know what is Hex Dump? I tried to search in google but
didn't get useful results. I know it is the hexademical representation
of something. But I don't know what is something?

Something can be anything that has a memory or disk representation. A
hexdump is simply a display of all the bytes in the object or file, as
hexadecimal values. Pretty trivial to write, usually.

Richard
 
D

Darrell Grainger

I want to know what is Hex Dump? I tried to search in google but
didn't get useful results. I know it is the hexademical representation
of something. But I don't know what is something? From C programmer's
perspective,
I always hear this term. But when do we need to use hex dump? what's
the importances of hex dump?

A hex dump is a utility to display the contents of memory or a file in a
grid of hexidecimal values. It typically has something like:

OFFSET: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
OFFSET: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
OFFSET: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
OFFSET: 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF

Where OFFSET is the offset from start of the file or it is a memory
address. The rest of the information is the hexidecimal values at those
locations.

It is useful for examining binary data. If I am using something like fread
and fwrite to read and write structures, I can do a hex dump to examine
the data and see what it looks like. It is a fast way to see if some of
the data is not getting generated properly.
 
E

Emmanuel Delahaye

(supersedes <[email protected]>)

Matt wrote on 29/07/04 :
I want to know what is Hex Dump?

It has nothing do do with C programming. It's just a way of
representing some memory area. Hex stands for 'hexadecimal', I presume.

For example, say that we have an int with the value 0x1234:

int n = 0x1234;

an 'hex dump' of n will give the memory representation of the value on
the current platform.

For example:

"34 12" on a x86 16-bit
"34 12 00 00" on a x86 32-bit
"00 00 12 34" on a 68000

etc.

Of course you can write a C-function that does the job of converting
the data area (address, length) into an hexadecimal representation.

void hexdump (void *p_data, size_t length)
{
/* now it's your turn to work on! */
}
 
M

Malcolm

Matt said:
I want to know what is Hex Dump? I tried to search in google but
didn't get useful results. I know it is the hexademical representation
of something. But I don't know what is something?
Other people have answered this.
From C programmer's perspective,I always hear this term.
C allows direct manipulation of memory bits, and also hexadecimal constants
eg
int x = 0xFEED;

So though strictly a hex dump has nothing to do with C, it is something that
you might need to when C programming.
But when do we need to use hex dump? what's the importances of hex dump?
A typical use would be this. You have a file which you know is a image, but
someone has lost the format. You also have, for the sake of argument, a
graphics editor which generates files in this format.
What do you do? Well a reasonable strategy would be to create a completely
black image, then hex dump the file. The hex dump is

00 64 00 32 00 00 00 00 00 ... (all zeroes)

We know that the image is 100 pixels wide and 50 pixels high. So it is
pretty obvious that the format is width (16 bits big-endian), height (16
bits big-endian) pixel data. We can generate more images to double-check.
 
R

RoSsIaCrIiLoIA

Matt wrote on 29/07/04 :

It has nothing do do with C programming. It's just a way of
representing some memory area. Hex stands for 'hexadecimal', I presume.

FOr example, say that we have an int with the value 0x1234:

int n = 0x1234;

an 'hex dump' of n will give the memory representation of the value on
the current platform.

For example:

"34 12" on a x86 16-bit
"34 12 00 00" on a x86 32-bit
I like this
"00 00 12 34" on a 68000
more than this

exist this?

43 21 00 00
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top