Can you please explain the difference between array_name and &array_name?
Submitted by: MuhammadOne is a pointer to the first element in the array; the other is a pointer to the array as a whole.
An array is a type. It has a base type (what it's an array of ), a size (unless it's an "incomplete" array), and a value (the value of the whole array). You can get a pointer to this value:
char a[ MAX ]; /* array of MAX characters */
char *p; /* pointer to one character */
/* pa is declared below */
pa = & a;
p = a; /* = & a[ 0 ] */
After running that code fragment, you might find that p and pa would be printed as the same value; they both point to the same address. They point to different types of MAX characters.
The wrong answer is
char *( ap[ MAX ] );
which is the same as this:
char *ap[ MAX ];
This code reads, "ap is an array of MAX pointers to characters."
Submitted by: Muhammad
An array is a type. It has a base type (what it's an array of ), a size (unless it's an "incomplete" array), and a value (the value of the whole array). You can get a pointer to this value:
char a[ MAX ]; /* array of MAX characters */
char *p; /* pointer to one character */
/* pa is declared below */
pa = & a;
p = a; /* = & a[ 0 ] */
After running that code fragment, you might find that p and pa would be printed as the same value; they both point to the same address. They point to different types of MAX characters.
The wrong answer is
char *( ap[ MAX ] );
which is the same as this:
char *ap[ MAX ];
This code reads, "ap is an array of MAX pointers to characters."
Submitted by: Muhammad
Read Online Data Structure Arrays Job Interview Questions And Answers
Top Data Structure Arrays Questions
☺ | What will be output if you will execute following c code? |
☺ | What is Array? |
☺ | What is two-dimensional array? |
☺ | Explain Array of pointers? |
☺ | Tell me why can\'t constant values be used to define an array\'s initial size |
Top Data Structure Categories
☺ | Data Center Manager Interview Questions. |
☺ | Sort And Searching Interview Questions. |
☺ | Creative UI/UX Designers Interview Questions. |
☺ | Data Structure Linked list Interview Questions. |
☺ | Data Structure Arrays Interview Questions. |