Path: utzoo!attcan!uunet!wuarchive!usc!isi.edu!gremlin!wind!kkenny From: kkenny@wind.nrtc.northrop.com (Kevin B. Kenny KE9TV) Newsgroups: comp.lang.c Subject: Re: Converting ascii hex values to hex bytes Summary: Use the system library when it's available... Keywords: inet, inet Message-ID: <11563@gremlin.nrtc.northrop.com> Date: 24 Oct 90 16:52:52 GMT References: <298@cti1.UUCP> <1990Oct23.220754.15958@uunet!unhd> Sender: news@gremlin.nrtc.northrop.com Reply-To: ke9tv@nrtc.northrop.com Followup-To: comp.lang.c Distribution: comp Organization: Northrop Research & Technology Center, Palos Verdes, CA Lines: 28 In article <298@cti1.UUCP> mpledger@cti1.UUCP (Mark Pledger) writes: >What I want to do is to be able to convert 122.10.10.44 into a >character string of 4 bytes that equals "\x7a\x0a\x0a\x2c". How can >I convert the ascii representation into hex? I tried using itoa(), >but the result is in ascii character format If you're on a 4.x BSD machine, or another one that has the `inet' library, the accepted way to parse Internet addresses is: ---------------------------------------- #include #include #include #include ... char * address_in_dotted_form; unsigned long parsed_address; ... parsed_address = inet_addr (address_in_dotted_form); ---------------------------------------- The manual page for this is inet(3n). Kevin, KE9TV