Re: A Query in "Pointers to Structures"
- From: Joe Wright <joewwright@xxxxxxxxxxx>
- Date: Sat, 15 Jul 2006 11:34:15 -0400
dbz wrote:
Hello everyone. I have a query. Lets say that following is given:-Nothing yet. You have declared a structure and defined a pointer to it, but you don't have a structure yet.
struct struct1{
char *word;
int n;
} *p;
QUERIES:
What does the following refer to?
1) p->word
2) (*p)->n
3) (*p)->word
4) *(p->word)
p = malloc(sizeof *p);
Now, assuming success of malloc, p points to a structure and p[0] is the structure.
1. p->word is just fine.
2. p->n or (*p).n or p[0].n
3. (*p).word or p[0].word
4. *(p->word) is just fine.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
.
- Follow-Ups:
- Re: A Query in "Pointers to Structures"
- From: Eric Sosman
- Re: A Query in "Pointers to Structures"
- References:
- A Query in "Pointers to Structures"
- From: dbz
- A Query in "Pointers to Structures"
- Prev by Date: Re: Problem with keyboard input for my very little OS
- Next by Date: Re: ungetc
- Previous by thread: Re: A Query in "Pointers to Structures"
- Next by thread: Re: A Query in "Pointers to Structures"
- Index(es):
Relevant Pages
|
|