delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/28/23:43:48

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199705290342.AA043377325@typhoon.rose.hp.com>
Subject: Re: Q: How to get an integer from a char table?
To: bhallstr AT abo DOT fi
Date: Wed, 28 May 1997 20:42:04 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <338b5879.5940154@news.abo.fi>; from "bhallstr@abo.fi" at May 27, 97 9:56 pm

> (unsigned char *foobar) and
> (unsigned int x). 
> x=foobar[10] does not seem to do it.
> 
This will cause GCC to get an 8 bit value and then promote it (sign
extend or zero extend) it to a sizteen bit value.  What you
want is to cast it to an int bit pointer before you deference it.

*((unsigned int*)(foobar+10))

Andrew

- Raw text -


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