Path: utzoo!utgpu!watserv1!watmath!att!att!linac!uwm.edu!rpi!bu.edu!purdue!mentor.cc.purdue.edu!shepherd From: shepherd@mentor.cc.purdue.edu (Mike Shepherd) Newsgroups: comp.lang.c Subject: Re: Pointers and addresses Message-ID: <15847@mentor.cc.purdue.edu> Date: 30 Oct 90 05:02:43 GMT References: <15831@mentor.cc.purdue.edu> <4139@goanna.cs.rmit.oz.au> Reply-To: shepherd@mentor.cc.purdue.edu (Mike Shepherd) Organization: Purdue University Lines: 65 In article <4139@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: >In article <15831@mentor.cc.purdue.edu>, > shepherd@mentor.cc.purdue.edu (Mike Shepherd) writes: >> Is there a way to change an integer into an address location, vice versa, an >> address location into an integer? > >What on earth is an address location? Do you mean a pointer? >How about an example of what you want to do? > >(I thought Purdue was supposed to be one of the really good places for >Comp Sci. Surely there must be _someone_ there who can give you face- >to-face help? That's bound to be better than the Net.) Well, someone apparently did know what I was talking about because someone DID give me help from the Net. And it worked out very well...here is what they wrote (and in a very nice and creative way if I might add) in case others of you are interested. And thanks again Xing! ... ---------------------------------------------------------- Subject: Re: Pointers and addresses Newsgroups: comp.lang.c In-Reply-To: <15831@mentor.cc.purdue.edu> Organization: Marquette University - Milwaukee, Wisconsin Message-Id: <9010292031.AA08370@compsys.mu.edu> Date: 29 Oct 90 20:31:59 CST (Mon) From: wuxing@comp.mscs.mu.edu (Xing Wu) Status: OR In article <15831@mentor.cc.purdue.edu> you write: >Is there a way to change an integer into an address location, vice versa, an >address location into an integer? >I keep getting illegal indirection & illegal pointer/integer comb errors. >Is this possible? This is just the compiler's way of saying "You know that it's just 32 bits, and I know that it's just 32 bits, but I'm clever enough to know that it's a *different type* of 32 bits." The thing to do is to use a "cast": char *s; int i; i = (int)s; s = (char *)i; etc. A cast is your way of saying "I'm clever enough to know that you're clever enough to know that it's a different type of 32 bits, so in your face." As I always say, "strong typing is for weak minds." ---------------------------------------------------------- And thanks again Xing...it worked perfect! Mike -- | Mike Shepherd (shepherd@mentor.cc.purdue.edu) | |-----------------------------------------------------------------------------| | Sometimes I think the surest sign that intelligent life exists elsewhere in | | the universe is that none of it has tried to contact us. --Calvin of C&H |