Question:
Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?
Answer:
It’s easier for a C compiler to generate good code for pointers than for subscripts. Source: CoolInterview.com
yes it is easier to navigate an array through pointer because if we are using pointers then we can make faster access to array elements as compared to accessing array elements through subscripted array names. Source: CoolInterview.com
Answered by: SAJAG RACHHORA | Date:
| Contact SAJAG RACHHORA
yes it is better to use a pointer to navigate an array of values because then we can access any element of array directly without accessing the values present before it. Source: CoolInterview.com
Answered by: JAYA GOYAL | Date:
| Contact JAYA GOYAL
it is better to use array subscript because if you are using a pointer variable you need two memory accesses one for getting the pointer data and the other is for actual data but if you are using array subscript we need only one memory acess Source: CoolInterview.com
Answered by: rekha | Date:
| Contact rekha
whether you access with pointer or with subscript ,both retrieve value within same time.because implicitly subscripts are internally implented as pointers. for eg: a[i] equivalent to *(a+i) Source: CoolInterview.com
Answered by: srinivas | Date:
| Contact srinivas
Yes, It is easy & efficient to use pointer to acces array elements because subscript finaly conveted to pointer notation by compiler. for ex. a[i] will converted by compiler as *(a+i). Source: CoolInterview.com
Answered by: Harishankar Singh | Date: 8/30/2007 4:12:17 PM
| Contact Harishankar Singh
It is better to use names rather than arrays because pointers are quite confusing and a small mistake could make large difference Source: CoolInterview.com
Answered by: karthican | Date: 9/1/2010
| Contact karthican
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|