Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by Steve Madsen
Wed, 22 Jul 1992 22:58
Stupid question: What does ** mean?
Author: Steve Madsen
Date: Wed, 22 Jul 1992 22:58
Date: Wed, 22 Jul 1992 22:58
10 lines
702 bytes
702 bytes
Here's an easy one. . .I'm stumped by the double asterisk declaration, for example: (int **) I've tried to locate it in Chapter 3, 6 and 7 of NextStep Concepts, as well as two different C manuals, so it's not a pure RTFM question (I hope). . . Thanks!! Steve Madsen
Re: Stupid question: What does ** mean?
Author: Michael S. Barthelemy
Date: Fri, 24 Jul 1992 13:37
Date: Fri, 24 Jul 1992 13:37
50 lines
1923 bytes
1923 bytes
In article <1992Jul22.225838.13892@vlsisj.uucp>
smadsen@leland.Stanford.EDU (Steve Madsen) writes:
> Here's an easy one. . .I'm stumped by the double asterisk declaration,
> for example:
>
> (int **)
>
> I've tried to locate it in Chapter 3, 6 and 7 of NextStep Concepts, as
> well as two different C manuals, so it's not a pure RTFM question (I
> hope). . .
It's a double pointer. (i.e. A pointer to another pointer.) If you were
to write:
int **temp;
It can be referenced several ways though.
temp[x] would give you the x'th element of the pointer array.
(which would be another pointer)
temp would give you the first element (pointer)
(such that temp has not been changed)
When mallocing one of these structures by yourself you will have to first
malloc for the first pointer to the array and then malloc off all of the
pointers to fill the array:
extern struct foo;
extern int numElements;
struct foo **fooItems;
{
int i;
fooItems = (struct foo **) malloc(sizeof(struct foo *) *
numElements);
for (i = 0; i < numElements; i++)
fooItems[i] = (struct foo *) malloc(sizeof(struct foo));
}
You can procede down the pointer path a long ways. The most I have ever
used are five and I am not sure if there is a limitation as to how many
one can have.
It happens to be referenced on pages 107-110 in K&R but they do not use a
terribly good example to show a double pointer.
Mike Barthelemy
msb@chromagrafx.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads