Xref: utzoo comp.lang.c:16602 comp.sys.amiga:29975 Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!eecae!dsacng1!dsacg1!dsacg2!nor1675 From: nor1675@dsacg2.UUCP (Michael Figg) Newsgroups: comp.lang.c,comp.sys.amiga Subject: printf in dump routine Keywords: printf, pointers Message-ID: <652@dsacg2.UUCP> Date: 28 Feb 89 19:04:52 GMT Organization: Defense Logistics Agency Systems Automation Center, Columbus Lines: 40 ----------------------------------------------------------------- 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