Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: how does one access a specific address location in C? Date: Thu, 16 Jun 2016 11:20:47 -0700 Organization: None to speak of Lines: 27 Message-ID: References: <994e7598-1570-4931-8cee-d5a7abb967a5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="32591"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CR/EaBB+dvmK5qbs69W+Q" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:8bQz9RBoEVHyWPW9pKwtFD3DrGU= sha1:P2WYxIYnV+naJs5vlawyJG41Pqg= Xref: csiph.com comp.lang.c:89316 James Kuyper writes: [...] > Other people have already answered you correctly, but I want to put a > somewhat different emphasis on my answer. > > For any given implementation, there might not be any way to do what > you're asking about. However, if there is, then the appropriate code is > very likely to be: > > int *pitwo = (int*)0x00000002; > char *pcsix = (char*)0x00000006; Note that the use of hexadecimal with leading zeros is mainly for the benefit of the reader, to emphasize that these are 32-bit numbers (and assuming a machine with 32-bit addresses). The above is exactly equivalent to: int *pitwo = (int*)2; char *pcsix = (char*)6; but the hex version is clearer. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"