:: Re: [DNG] Making sense of C pointer…
Kezdőlap
Delete this message
Reply to this message
Szerző: Steve Litt
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] Making sense of C pointer syntax.
On Mon, 28 Mar 2016 14:51:19 +0200 (CEST)
karl@??? wrote:

> Rainer Weikusat:
> ...
> > One thing to note here: Every C pointer is really a pointer to an
> > array of values, although the size of the array may just be one.
> ...
>
> I thought it was the other way around, a pointer is just an address to
> some (a single) memory location which can be part of an array


You're both right. A pointer is definitely an address of a single
memory address of a single byte or char or int or whatever, but that
single memory address *could* be the first element of an array, thus
defining the beginning location of the whole array. And of course the
end of the array must be defined by a second pointer, an integer
length, or a sentinel value such as '\0' or NULL.

char *p;
p="01234"; /* skeezy, but makes the point */
printf("p points to char %c\n", *p);
printf("p indicates start of string %s\n", p);


SteveT

Steve Litt
March 2016 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz