printf in dump routine
Michael Figg
nor1675 at dsacg2.UUCP
Wed Mar 1 05:04:52 AEST 1989
-----------------------------------------------------------------
Following is the relevent piece of code from a dump routine I have been
trying to write on an Amiga. I'm trying to pass a pointer to a variable
that I want to dump in hex and the number of bytes to print:
.
.
long test_long;
test_long = 1234;
print_data((char *)&test_long,sizeof(test_long));
.
.
void print_data(pnt,num)
char *pnt;
int num;
{
int i;
for(i = 0; i < num; i++)
{
printf("%02x",*(pnt + i));
}
}
.
What I would hope to get from this is '000004d2' but actually got
'000004ffffffd2'. This was done with Lattice v5.0.1. I also tried
similar code at work on a PC with MS v5.1. There I got 'ffd2040000',
which except for the leading 'ff' looks like it was printing the bytes
backwards. Any clues as to why I'm getting this output and how to do it
right? Thanks
->Mike<-
--
"Hot Damn! Groat Cakes Again Michael Figg
Heavy on the thirty weight!" DLA Systems Automation Center
Columbus, Oh.
(614)-238-9036
More information about the Comp.lang.c
mailing list