Message-ID: <388B549C.A2C038D@ou.edu> From: David Cleaver X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Weird output of printf() References: <388B34AB DOT CA34EBD9 AT ou DOT edu> <4nhm8s4eqkb8mvicavhlv866qio80e0h8l AT 4ax DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 57 Date: Sun, 23 Jan 2000 13:21:00 -0600 NNTP-Posting-Host: 129.15.140.115 X-Complaints-To: usenet AT ou DOT edu X-Trace: news.ou.edu 948655190 129.15.140.115 (Sun, 23 Jan 2000 13:19:50 CST) NNTP-Posting-Date: Sun, 23 Jan 2000 13:19:50 CST Organization: The University of Oklahoma To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, Well, if you really want to know the print line I'm using is: fprintf(out, "%#x", array0[looper1][looper2]); where array0 contains unsigned char's Anyway, does the compiler actually think that 0xf is the same as 0x0f? I personally think it should print out the leading zero, but, maybe thats just me. Is there a way to get it to print out that leading zero? The reason I'm asking is, if I want to change from char's to int's I just want to delete the "0x"'s from most of the char's. I'll give an example below... Ok, If I have four char's {0x0f, 0x0f, 0x01, 0x07} and I want to convert it to an int I just combine them all into: {0x0f0f0107} right? Please tell me if this is correct. So, would the compiler be able to recognize if I chaged the array: from {0xf, 0xf, 0x1, 0x7} to {0xff17}? I don't think so. So, I would like for printf (or fprintf) to print out the leading zero so I don't have to go back and add all of them. Any help that you can give will be appreciated very much. -David C. Damian Yerrick wrote: > > On Sun, 23 Jan 2000 11:04:43 -0600, David Cleaver > wrote: > > >Hello again everyone, > > > >First, I want everyone to know I'm using DJGPP v2.03. OK, now, recently > >I've tried to use the printf() function to print out the hex values of > >some unsigned char's that I have. However, I'm not sure that it always > >did just that. Let me give you an example: > > > >{ 0xbc, 0xf, 0}, > > > >This is part of the output of the program. My question is, WHAT does > >"0xf" mean????????? > > If you're using char to hold keypresses: > 0xf = binary 00001111 = ascii code for Ctrl+O > If you're using char as an 8-bit integer: > 0xf = decimal 15 > > Does your line look anything like this? > printf("character %c = 0x%x\n", c, (int)c); > > -- > Damian Yerrick http://yerricde.tripod.com/ > View full sig at http://www.rose-hulman.edu/~yerricde/sig.html > Comment on story ideas at http://home1.gte.net/frodo/quickjot.html