+ 1

What is a faster way of accessing arrays using ar[x] or by using pointers?

array elements access speed

5th Nov 2016, 2:39 PM
Megatron
Megatron - avatar
3 Answers
+ 1
i think both are pretty much same since array itself uses the name of its array as a pointer to access the elements.
5th Nov 2016, 3:09 PM
kamal joshi
kamal joshi - avatar
+ 1
thanks kamal. but accessing arrays using pointers is faster. you have rightly pointed that array itself uses the name of its base element as pointer So internally ar[x] is converted to pointer so if we use pointers it saves the compiler from doing it.
7th Nov 2016, 10:12 AM
Megatron
Megatron - avatar
0
By pointers I thought you meant "by taking some external pointer".And then make it point to array. I actually meant the same thing you have written.
7th Nov 2016, 10:19 AM
kamal joshi
kamal joshi - avatar