Is it better to use a pointer to navigate an array of values,or is it better to use a subscripted array name?

It’s easier for a C compiler to generate good code for pointers than for subscripts.  

Showing Answers 1 - 4 of 4 Answers

abc

  • Sep 15th, 2006
 

If its linear access it better to use pointers otherwise array name. Array names are faster since it can be used the subscription like a[10].

  Was this answer useful?  Yes

kbjarnason

  • Jul 2nd, 2010
 

The only "better" is what is more readable and maintainable and sensible to the people reading and writing the code.

Any compiler worth having won't care either way, and will generally produce identical or equivalently performing code in each case.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions