G
Ganesh
Hi,
This is a question that pertains to pointers in general (C or C++).
Which of the following is faster and why?
for (int i = 0; i < N; i++)
= ... a...
(or)
for (int i = 0; i < N; i++)
= ...*a++....
'a' is a dynamically allocated array of any valid scalar type and of
size N. I have read somewhere that the latter is faster. But could not
understand why? Or is that dependent on architecture or compiler?
This is a question that pertains to pointers in general (C or C++).
Which of the following is faster and why?
for (int i = 0; i < N; i++)
= ... a...
(or)
for (int i = 0; i < N; i++)
= ...*a++....
'a' is a dynamically allocated array of any valid scalar type and of
size N. I have read somewhere that the latter is faster. But could not
understand why? Or is that dependent on architecture or compiler?