delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/20/03:15:51

Date: Thu, 20 Jan 2000 08:56:20 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Wormy <wormy AT technologist DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Casting pointers
In-Reply-To: <865adi$tbm$1@bird.wu-wien.ac.at>
Message-ID: <Pine.SUN.3.91.1000120085556.21977N@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 19 Jan 2000, Wormy wrote:

> textstring[0] = 0x50;
> textstring[1] = 0xFF;
> textstring[2] = 0x33;
> textstring[3] = 0x50;
> textstring[4] = 0x56;
> textstring[5] = 0x80;
> 
> It's simple to get ONE BYTE when doing a printf ("%d\n",textstring[0]);
> 
> But is there a way to get a long representation of the first 4 Bytes - with
> a pointer cast or so...
> like I would do with a
> char *memory
> and do something like (long *)memory or (short *)memory...
> 
> What I would like is to get - thanks to a cast - the value 0x50FF3350

Use htonl(*(long *)textstring).  `htonl' is a library function
declared in the header <netinet/in.h>.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019