Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Summary: Converting ascii hex to pure hex values Message-ID: <14367@smoke.brl.mil> Date: 7 Nov 90 09:19:09 GMT References: <302@cti1.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 20 In article <302@cti1.UUCP> mpledger@cti1.UUCP (Mark Pledger) writes: >If you have a character string with the ascii representation of hex values >(e.g. s[] = "63", which will be stored as TWO hex byte values \x9 & \x9. No, the two successive values will be 0x36 and 0x33. >I only want to store them as ONE hex byte of \x63. ... I am interested in >creating (or finding) a routine that will take a character string as the >argument, and returning the hex result in the same character string. This is a trivial exercise. WARNING: String literals (as opposed to arrays of char) are not necessarily modifiable. void func( char *s ) { register int i = s[0] - '0' << 4 | s[1] - '0'; s[0] = i; s[1] = '\0'; } This could be easily be made into a macro.