Mail Archives: djgpp/1996/04/01/10:09:05
Xref: | news2.mv.net comp.os.msdos.djgpp:2319
|
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: How to code Interrupts in C?
|
Date: | Sun, 31 Mar 1996 15:53:19 -0800
|
Organization: | Alcyone Systems
|
Lines: | 23
|
Message-ID: | <315F1AEF.5A083C32@alcyone.com>
|
References: | <4ji0s3$t4i AT news DOT nevada DOT edu>
|
NNTP-Posting-Host: | newton.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
GEORGE GAGHON wrote:
> int w_stuff
> long l_stufftoo
> byte b_stuffalso
>
> w_stuff = *p <---- will this grab a word at location p
> l_stufftoo = *(p+2)<---- will this grab a long ?
> b_stuffalso = *(p+6) <--- and this will grab a byte, right?
No. It depends on what kind of pointer p is. Say that p is declared as a
char *. Then *p (or, equivalently, p[0]) would get the char at p, *(p + 2)
(or p[2]) would get the char at p + 2, and *(p + 6) (p[6]) would get the char
at p + 6. Since the pointer is a char * (or whatever), dereferencing it gives
you a char (or whatever). If you want to dereference to get other values, you
have to explicitly cast it before dereferencing; i.e., *(int *) p.
--
Erik Max Francis &tSftDotIotE && http://www.alcyone.com/max && max AT alcyone DOT com
San Jose, California, U.S.A. && 37 20 07 N 121 53 38 W && the 4th R is respect
H.3`S,3,P,3$S,#$Q,C`Q,3,P,3$S,#$Q,3`Q,3,P,C$Q,#(Q.#`-"C`- && 1love && folasade
Omnia quia sunt, lumina sunt. && Dominion, GIGO, GOOGOL, Omega, Psi, Strategem
"Out from his breast/his soul went to seek/the doom of the just." -- _Beowulf_
- Raw text -