Re: pointer q
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sun, 14 May 2006 02:14:42 GMT
"Joe Smith" <grumpy196884@xxxxxxxxxxx> writes:
"Keith Thompson" <kst-u@xxxxxxx> wrote in message
news:lnlkt5bqv3.fsf@xxxxxxxxxxxxxxxxxx
"Joe Smith" <grumpy196884@xxxxxxxxxxx> writes:
A recent post of mine showed a sufficiently large gaffe on pointers as to
need to return to K&R 5.1-6 appendix A8.6.1 . So we have type
specifiers:
int
long
. One dreams himself variable names: qwe, qwr, writes
int qwe;
long qwr;
and thinks he knows what types he's declared. Had you asked me about:
int *qwe;
long *qwr;
I would have said the pointers declared were--while pointng to different
types--of the same type. Why am I wrong? Joe
int* and long* are two different types (both pointer types).
I'm curious, what led you to think that they're the same type?
What's to stop me from swapping an int * and a long *? Joe
Um, they're different types. Given:
int *ip;
long *lp;
these assignments:
ip = lp;
lp = ip;
are both illegal (constraint violations requiring diagnostics).
You can do the assignments with explicit conversion (casts), but
there's no guarantee that the results will be meaningful.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- pointer q
- From: Joe Smith
- Re: pointer q
- From: Keith Thompson
- Re: pointer q
- From: Joe Smith
- pointer q
- Prev by Date: Re: Bitwise AND etc
- Next by Date: Re: Array and Pointer Tutorial
- Previous by thread: Re: pointer q
- Next by thread: Re: pointer q
- Index(es):
Relevant Pages
|